Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add moderation timestamp to Question #6390

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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:
Expand All @@ -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))
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit. Maybe use moderated instead of moderation_timestamp to match the style of the other date-time fields like created and updated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I spent some time on this. I had moderated but then I switched to more verbose naming schema which avoids confussion. When I am thinking of moderated I default to whether the question is moderated or not and I am not thinking timestamp.


update_topic_counter = models.IntegerField(default=0)

Expand Down