From de2aea2c31292007be3f7abb277a743cd760bb63 Mon Sep 17 00:00:00 2001 From: Tasos Katsoulas Date: Wed, 4 Dec 2024 17:48:40 +0200 Subject: [PATCH] Remove bug_support option Route bug_suppoert selection to moderation tool --- kitsune/flagit/jinja2/flagit/queue.html | 3 --- .../0004_alter_flaggedobject_reason.py | 27 +++++++++++++++++++ kitsune/flagit/models.py | 2 -- kitsune/flagit/views.py | 12 ++++++--- .../jinja2/questions/question_details.html | 2 +- .../wiki/jinja2/wiki/includes/flag_form.html | 13 +++++---- 6 files changed, 43 insertions(+), 16 deletions(-) create mode 100644 kitsune/flagit/migrations/0004_alter_flaggedobject_reason.py diff --git a/kitsune/flagit/jinja2/flagit/queue.html b/kitsune/flagit/jinja2/flagit/queue.html index 6555593d484..ad10de391dc 100644 --- a/kitsune/flagit/jinja2/flagit/queue.html +++ b/kitsune/flagit/jinja2/flagit/queue.html @@ -28,9 +28,6 @@


{{ _('Update Status:') }}

{% elif object.reason == "abuse" %} - {% elif object.reason == "bug_support" %} - - {% elif object.reason == "language" %} diff --git a/kitsune/flagit/migrations/0004_alter_flaggedobject_reason.py b/kitsune/flagit/migrations/0004_alter_flaggedobject_reason.py new file mode 100644 index 00000000000..bc11060e588 --- /dev/null +++ b/kitsune/flagit/migrations/0004_alter_flaggedobject_reason.py @@ -0,0 +1,27 @@ +# Generated by Django 4.2.16 on 2024-12-04 06:42 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("flagit", "0003_alter_flaggedobject_reason"), + ] + + operations = [ + migrations.AlterField( + model_name="flaggedobject", + name="reason", + field=models.CharField( + choices=[ + ("spam", "Spam or other unrelated content"), + ("language", "Inappropriate language/dialog"), + ("abuse", "Abusive content"), + ("other", "Other (please specify)"), + ], + default="spam", + max_length=64, + ), + ), + ] diff --git a/kitsune/flagit/models.py b/kitsune/flagit/models.py index f816e0d9dc9..5e70014258c 100644 --- a/kitsune/flagit/models.py +++ b/kitsune/flagit/models.py @@ -20,14 +20,12 @@ class FlaggedObject(ModelBase): REASON_SPAM = "spam" REASON_LANGUAGE = "language" - REASON_BUG_SUPPORT = "bug_support" REASON_ABUSE = "abuse" REASON_CONTENT_MODERATION = "content_moderation" REASON_OTHER = "other" REASONS = ( (REASON_SPAM, _lazy("Spam or other unrelated content")), (REASON_LANGUAGE, _lazy("Inappropriate language/dialog")), - (REASON_BUG_SUPPORT, _lazy("Misplaced bug report or support request")), (REASON_ABUSE, _lazy("Abusive content")), (REASON_OTHER, _lazy("Other (please specify)")), ) diff --git a/kitsune/flagit/views.py b/kitsune/flagit/views.py index 4534ba6daca..655203a3d74 100644 --- a/kitsune/flagit/views.py +++ b/kitsune/flagit/views.py @@ -61,12 +61,11 @@ def flag(request, content_type=None, model=None, object_id=None, **kwargs): notes = request.POST.get("other", "") next = request.POST.get("next") - FlaggedObject.objects.filter( + moderation_flag = FlaggedObject.objects.filter( content_type=content_type, object_id=object_id, reason=FlaggedObject.REASON_CONTENT_MODERATION, - status=FlaggedObject.FLAG_PENDING, - ).delete() + ) # Check that this user hasn't already flagged the object _flagged, created = FlaggedObject.objects.get_or_create( content_type=content_type, @@ -74,6 +73,13 @@ def flag(request, content_type=None, model=None, object_id=None, **kwargs): creator=request.user, defaults={"content_object": content_object, "reason": reason, "notes": notes}, ) + if reason == FlaggedObject.REASON_CONTENT_MODERATION: + moderation_flag.update(status=FlaggedObject.FLAG_PENDING) + # If the object is flagged again as pending, treat it as new flag + created = True + else: + moderation_flag.delete() + msg = ( _("You already flagged this content.") if not created diff --git a/kitsune/questions/jinja2/questions/question_details.html b/kitsune/questions/jinja2/questions/question_details.html index eacb2de5c5c..af0ae25307e 100644 --- a/kitsune/questions/jinja2/questions/question_details.html +++ b/kitsune/questions/jinja2/questions/question_details.html @@ -165,7 +165,7 @@

more options diff --git a/kitsune/wiki/jinja2/wiki/includes/flag_form.html b/kitsune/wiki/jinja2/wiki/includes/flag_form.html index 07715838054..eadcccf260a 100644 --- a/kitsune/wiki/jinja2/wiki/includes/flag_form.html +++ b/kitsune/wiki/jinja2/wiki/includes/flag_form.html @@ -1,4 +1,4 @@ -{% macro flag_form(post_target, identifier, bug_support=True) %} +{% macro flag_form(post_target, identifier, content_moderation=False) %} {{ _('Report Abuse') }}

{{ _('Report this') }}

@@ -12,11 +12,11 @@

{{ _('Report this') }}

- {% if bug_support %} -
- - -
+ {% if content_moderation %} +
+ + +
{% endif %}
@@ -34,7 +34,6 @@

{{ _('Report this') }}

-
{% endmacro %} \ No newline at end of file