diff --git a/kitsune/flagit/views.py b/kitsune/flagit/views.py index 5f6f12268e9..9fb83a2bad3 100644 --- a/kitsune/flagit/views.py +++ b/kitsune/flagit/views.py @@ -4,6 +4,7 @@ from django.contrib.contenttypes.models import ContentType from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import get_object_or_404, render +from django.utils import timezone from django.utils.translation import gettext as _ from django.views.decorators.http import require_POST @@ -175,9 +176,9 @@ def update(request, flagged_object_id): new_status = request.POST.get("status") reason = request.GET.get("reason") product = request.GET.get("product") + ct = flagged.content_type if new_status: - ct = flagged.content_type # If the object is an Answer let's fire a notification # if the flag is invalid if str(new_status) == str(FlaggedObject.FLAG_REJECTED) and ct.model_class() == Answer: @@ -187,5 +188,8 @@ def update(request, flagged_object_id): flagged.status = new_status flagged.save() if flagged.reason == FlaggedObject.REASON_CONTENT_MODERATION: + question = flagged.content_object + question.moderation_timestamp = timezone.now() + question.save() return HttpResponseRedirect(urlparams(reverse("flagit.moderate_content"), product=product)) return HttpResponseRedirect(urlparams(reverse("flagit.flagged_queue"), reason=reason)) diff --git a/kitsune/questions/migrations/0020_question_moderation_timestamp.py b/kitsune/questions/migrations/0020_question_moderation_timestamp.py new file mode 100644 index 00000000000..111b9ab6a81 --- /dev/null +++ b/kitsune/questions/migrations/0020_question_moderation_timestamp.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.16 on 2024-12-04 01:50 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("questions", "0019_alter_aaqconfig_associated_tags_alter_question_tags"), + ] + + operations = [ + migrations.AddField( + model_name="question", + name="moderation_timestamp", + field=models.DateTimeField(default=None, null=True), + ), + ] diff --git a/kitsune/questions/models.py b/kitsune/questions/models.py index a1dba3a3063..ba61eabded6 100755 --- a/kitsune/questions/models.py +++ b/kitsune/questions/models.py @@ -147,6 +147,7 @@ class Question(AAQBase): tags_cache_key = "question:tags:%s" images_cache_key = "question:images:%s" contributors_cache_key = "question:contributors:%s" + moderation_timestamp = models.DateTimeField(default=None, null=True) update_topic_counter = models.IntegerField(default=0)