From 3d9e2cd8d8e848bf3b5502a8afc84fa09cc25fa8 Mon Sep 17 00:00:00 2001 From: Tasos Katsoulas Date: Thu, 31 Oct 2024 18:55:54 +0200 Subject: [PATCH] Do not allow the creation of new tags --- kitsune/questions/api.py | 9 ++-- .../jinja2/questions/question_details.html | 6 +-- kitsune/questions/tests/test_api.py | 18 ------- kitsune/questions/tests/test_templates.py | 12 ++--- kitsune/questions/views.py | 18 ++----- kitsune/sumo/static/sumo/js/tags.js | 51 +++++++++---------- kitsune/tags/forms.py | 7 +-- 7 files changed, 40 insertions(+), 81 deletions(-) diff --git a/kitsune/questions/api.py b/kitsune/questions/api.py index 5a30136c9b1..dd382e3db73 100644 --- a/kitsune/questions/api.py +++ b/kitsune/questions/api.py @@ -387,12 +387,9 @@ def add_tags(self, request, pk=None): try: add_existing_tag(tag, question.tags) except Tag.DoesNotExist: - if request.user.has_perm("taggit.add_tag"): - question.tags.add(tag) - else: - raise GenericAPIException( - status.HTTP_403_FORBIDDEN, "You are not authorized to create new tags." - ) + raise GenericAPIException( + status.HTTP_403_FORBIDDEN, "You are not authorized to create new tags." + ) data = [{"name": tag.name, "slug": tag.slug} for tag in question.tags.all()] return Response(data) diff --git a/kitsune/questions/jinja2/questions/question_details.html b/kitsune/questions/jinja2/questions/question_details.html index 24f99d5c81b..47296947f01 100644 --- a/kitsune/questions/jinja2/questions/question_details.html +++ b/kitsune/questions/jinja2/questions/question_details.html @@ -390,7 +390,7 @@

{{ _('Post a Reply') }}

{% set tags = question.my_tags %} {% if tags or can_tag %}