Skip to content

Commit

Permalink
adjustments based on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
escattone committed Jan 23, 2025
1 parent f06b1a2 commit f255285
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions kitsune/flagit/jinja2/flagit/content_moderation.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ <h3 class="sumo-card-heading"><br>{{ _('Update Status:') }}</h3>
<div id="my-queue-tools" data-current-username="{{ current_username }}"
{% if not (selected_assignee and (selected_assignee == current_username)) %} hidden{% endif %}>
<label>{{ _('Manage my queue') }}:</label>
<form id="my-queue-assign" hx-post="" hx-target="#flagged-queue" hx-select="#flagged-queue">
<form hx-post="" hx-target="#flagged-queue" hx-select="#flagged-queue">
{% csrf_token %}
<input type="hidden" name="action" value="assign">
<input class="sumo-button secondary-button button-lg btn" type="submit" value="{{ _('Assign more') }}" />
<input class="sumo-button primary-button button-lg btn" type="submit" value="{{ _('Assign more') }}" />
</form>
<form id="my-queue-unassign" hx-post="" hx-target="#flagged-queue" hx-select="#flagged-queue">
{% csrf_token %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.18 on 2025-01-16 09:37
# Generated by Django 4.2.18 on 2025-01-23 08:29

from django.conf import settings
from django.db import migrations, models
Expand All @@ -15,7 +15,7 @@ class Migration(migrations.Migration):
operations = [
migrations.AddField(
model_name="flaggedobject",
name="assigned",
name="assigned_timestamp",
field=models.DateTimeField(default=None, null=True),
),
migrations.AddField(
Expand Down
2 changes: 1 addition & 1 deletion kitsune/flagit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class FlaggedObject(ModelBase):
assignee = models.ForeignKey(
User, on_delete=models.SET_NULL, null=True, related_name="assigned_flags"
)
assigned = models.DateTimeField(default=None, null=True)
assigned_timestamp = models.DateTimeField(default=None, null=True)

objects = FlaggedObjectManager()

Expand Down
24 changes: 13 additions & 11 deletions kitsune/flagit/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,20 +177,20 @@ def moderate_content(request):
product_slug = request.GET.get("product")
assignee = request.GET.get("assignee")

if (
assignee
and not User.objects.filter(
is_active=True, username=assignee, groups__name="Content Moderators"
).exists()
):
return HttpResponseNotFound()

if request.method == "POST":
if not (assignee and (request.user.username == assignee)):
return HttpResponseForbidden()
action = request.POST.get("action")
if not (action and (action in ("assign", "unassign"))):
return HttpResponseBadRequest()
else:
if (
assignee
and not User.objects.filter(
is_active=True, username=assignee, groups__name="Content Moderators"
).exists()
):
return HttpResponseNotFound()

content_type = ContentType.objects.get_for_model(Question)
objects = (
Expand All @@ -207,10 +207,12 @@ def moderate_content(request):
if action == "assign":
# Assign another batch of objects to the user.
assigment_qs = objects.filter(assignee__isnull=True)[:20].values_list("id", flat=True)
objects.filter(id__in=assigment_qs).update(assignee=request.user, assigned=Now())
objects.filter(id__in=assigment_qs).update(
assignee=request.user, assigned_timestamp=Now()
)
else:
# Unassign all of the user's objects.
objects.filter(assignee=request.user).update(assignee=None, assigned=None)
objects.filter(assignee=request.user).update(assignee=None, assigned_timestamp=None)

if assignee:
objects = objects.filter(assignee__username=assignee)
Expand Down Expand Up @@ -274,7 +276,7 @@ def update(request, flagged_object_id):

flagged.status = new_status
flagged.assignee = None
flagged.assigned = None
flagged.assigned_timestamp = None
flagged.save()
if flagged.reason == FlaggedObject.REASON_CONTENT_MODERATION:
question = flagged.content_object
Expand Down

0 comments on commit f255285

Please sign in to comment.