Skip to content

Commit

Permalink
Merge pull request #6396 from akatsoulas/dup-mod-entries
Browse files Browse the repository at this point in the history
Introduce duplicate flags
  • Loading branch information
akatsoulas authored Dec 5, 2024
2 parents dd2fa1b + 4a0d9c2 commit d9aa9b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions kitsune/flagit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class FlaggedObject(ModelBase):
FLAG_PENDING = 0
FLAG_ACCEPTED = 1
FLAG_REJECTED = 2
FLAG_DUPLICATE = 3
STATUSES = (
(FLAG_PENDING, _lazy("Pending")),
(FLAG_ACCEPTED, _lazy("Accepted and Fixed")),
Expand Down
18 changes: 9 additions & 9 deletions kitsune/flagit/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,25 @@ def flag(request, content_type=None, model=None, object_id=None, **kwargs):
notes = request.POST.get("other", "")
next = request.POST.get("next")

moderation_flag = FlaggedObject.objects.filter(
moderation_flag_query = FlaggedObject.objects.filter(
content_type=content_type,
object_id=object_id,
reason=FlaggedObject.REASON_CONTENT_MODERATION,
)
default_kwargs = {"content_object": content_object, "reason": reason, "notes": notes}
if reason == FlaggedObject.REASON_CONTENT_MODERATION:
moderation_flag_query.update(status=FlaggedObject.FLAG_PENDING)
default_kwargs["status"] = FlaggedObject.FLAG_DUPLICATE
else:
moderation_flag_query.delete()

# Check that this user hasn't already flagged the object
_flagged, created = FlaggedObject.objects.get_or_create(
content_type=content_type,
object_id=object_id,
creator=request.user,
defaults={"content_object": content_object, "reason": reason, "notes": notes},
defaults=default_kwargs,
)
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
Expand Down

0 comments on commit d9aa9b1

Please sign in to comment.