Skip to content

Commit

Permalink
Merge pull request #6390 from akatsoulas/moderation-timestamp
Browse files Browse the repository at this point in the history
Add moderation timestamp to Question
  • Loading branch information
akatsoulas authored Dec 5, 2024
2 parents 1e370e7 + cc39aa5 commit 1916951
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kitsune/flagit/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -173,9 +174,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:
Expand All @@ -185,5 +186,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))
18 changes: 18 additions & 0 deletions kitsune/questions/migrations/0020_question_moderation_timestamp.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
1 change: 1 addition & 0 deletions kitsune/questions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 1916951

Please sign in to comment.