mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2026-02-05 16:15:19 -05:00
feat: add passkey authentication and enhance user preferences - Add passkey login security event type with fingerprint icon - Include request and site context in email confirmation for backend - Add user_id exact match filter to prevent incorrect user lookups - Enable PATCH method for updating user preferences via API - Add moderation_preferences support to user settings - Optimize ticket queries with select_related and prefetch_related This commit introduces passkey authentication tracking, improves user profile filtering accuracy, and extends the preferences API to support updates. Query optimizations reduce database hits for ticket listings.
1094 lines
37 KiB
Python
1094 lines
37 KiB
Python
"""
|
|
Rich Choice Objects for Moderation Domain
|
|
|
|
This module defines all choice options for the moderation system using the Rich Choice Objects pattern.
|
|
All choices include rich metadata for UI styling, business logic, and enhanced functionality.
|
|
"""
|
|
|
|
from apps.core.choices.base import ChoiceCategory, RichChoice
|
|
from apps.core.choices.registry import register_choices
|
|
|
|
# ============================================================================
|
|
# EditSubmission Choices
|
|
# ============================================================================
|
|
|
|
EDIT_SUBMISSION_STATUSES = [
|
|
RichChoice(
|
|
value="PENDING",
|
|
label="Pending",
|
|
description="Submission awaiting moderator review",
|
|
metadata={
|
|
"color": "yellow",
|
|
"icon": "clock",
|
|
"css_class": "bg-yellow-100 text-yellow-800 border-yellow-200",
|
|
"sort_order": 1,
|
|
"can_transition_to": ["CLAIMED"], # Must be claimed before any action
|
|
"requires_moderator": True,
|
|
"is_actionable": True,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
RichChoice(
|
|
value="CLAIMED",
|
|
label="Claimed",
|
|
description="Submission has been claimed by a moderator for review",
|
|
metadata={
|
|
"color": "blue",
|
|
"icon": "user-check",
|
|
"css_class": "bg-blue-100 text-blue-800 border-blue-200",
|
|
"sort_order": 2,
|
|
# Note: PENDING not included to avoid cycle - unclaim uses direct status update
|
|
"can_transition_to": ["APPROVED", "REJECTED", "ESCALATED"],
|
|
"requires_moderator": True,
|
|
"is_actionable": True,
|
|
"is_locked": True, # Indicates this submission is locked for editing by others
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
RichChoice(
|
|
value="APPROVED",
|
|
label="Approved",
|
|
description="Submission has been approved and changes applied",
|
|
metadata={
|
|
"color": "green",
|
|
"icon": "check-circle",
|
|
"css_class": "bg-green-100 text-green-800 border-green-200",
|
|
"sort_order": 3,
|
|
"can_transition_to": [],
|
|
"requires_moderator": True,
|
|
"is_actionable": False,
|
|
"is_final": True,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
RichChoice(
|
|
value="REJECTED",
|
|
label="Rejected",
|
|
description="Submission has been rejected and will not be applied",
|
|
metadata={
|
|
"color": "red",
|
|
"icon": "x-circle",
|
|
"css_class": "bg-red-100 text-red-800 border-red-200",
|
|
"sort_order": 4,
|
|
"can_transition_to": [],
|
|
"requires_moderator": True,
|
|
"is_actionable": False,
|
|
"is_final": True,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
RichChoice(
|
|
value="ESCALATED",
|
|
label="Escalated",
|
|
description="Submission has been escalated for higher-level review",
|
|
metadata={
|
|
"color": "purple",
|
|
"icon": "arrow-up",
|
|
"css_class": "bg-purple-100 text-purple-800 border-purple-200",
|
|
"sort_order": 5,
|
|
"can_transition_to": ["APPROVED", "REJECTED"],
|
|
"requires_moderator": True,
|
|
"is_actionable": True,
|
|
"escalation_level": "admin",
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
]
|
|
|
|
SUBMISSION_TYPES = [
|
|
RichChoice(
|
|
value="EDIT",
|
|
label="Edit Existing",
|
|
description="Modification to existing content",
|
|
metadata={
|
|
"color": "blue",
|
|
"icon": "pencil",
|
|
"css_class": "bg-blue-100 text-blue-800 border-blue-200",
|
|
"sort_order": 1,
|
|
"requires_existing_object": True,
|
|
"complexity_level": "medium",
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="CREATE",
|
|
label="Create New",
|
|
description="Creation of new content",
|
|
metadata={
|
|
"color": "green",
|
|
"icon": "plus-circle",
|
|
"css_class": "bg-green-100 text-green-800 border-green-200",
|
|
"sort_order": 2,
|
|
"requires_existing_object": False,
|
|
"complexity_level": "high",
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="PHOTO",
|
|
label="Photo Submission",
|
|
description="Photo upload for existing content",
|
|
metadata={
|
|
"color": "purple",
|
|
"icon": "photograph",
|
|
"css_class": "bg-purple-100 text-purple-800 border-purple-200",
|
|
"sort_order": 3,
|
|
"requires_existing_object": True,
|
|
"complexity_level": "low",
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
]
|
|
|
|
# ============================================================================
|
|
# ModerationReport Choices
|
|
# ============================================================================
|
|
|
|
MODERATION_REPORT_STATUSES = [
|
|
RichChoice(
|
|
value="PENDING",
|
|
label="Pending Review",
|
|
description="Report awaiting initial moderator review",
|
|
metadata={
|
|
"color": "yellow",
|
|
"icon": "clock",
|
|
"css_class": "bg-yellow-100 text-yellow-800 border-yellow-200",
|
|
"sort_order": 1,
|
|
"can_transition_to": ["UNDER_REVIEW", "DISMISSED"],
|
|
"requires_assignment": False,
|
|
"is_actionable": True,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
RichChoice(
|
|
value="UNDER_REVIEW",
|
|
label="Under Review",
|
|
description="Report is actively being investigated by a moderator",
|
|
metadata={
|
|
"color": "blue",
|
|
"icon": "eye",
|
|
"css_class": "bg-blue-100 text-blue-800 border-blue-200",
|
|
"sort_order": 2,
|
|
"can_transition_to": ["RESOLVED", "DISMISSED"],
|
|
"requires_assignment": True,
|
|
"is_actionable": True,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
RichChoice(
|
|
value="RESOLVED",
|
|
label="Resolved",
|
|
description="Report has been resolved with appropriate action taken",
|
|
metadata={
|
|
"color": "green",
|
|
"icon": "check-circle",
|
|
"css_class": "bg-green-100 text-green-800 border-green-200",
|
|
"sort_order": 3,
|
|
"can_transition_to": [],
|
|
"requires_assignment": True,
|
|
"is_actionable": False,
|
|
"is_final": True,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
RichChoice(
|
|
value="DISMISSED",
|
|
label="Dismissed",
|
|
description="Report was reviewed but no action was necessary",
|
|
metadata={
|
|
"color": "gray",
|
|
"icon": "x-circle",
|
|
"css_class": "bg-gray-100 text-gray-800 border-gray-200",
|
|
"sort_order": 4,
|
|
"can_transition_to": [],
|
|
"requires_assignment": True,
|
|
"is_actionable": False,
|
|
"is_final": True,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
]
|
|
|
|
PRIORITY_LEVELS = [
|
|
RichChoice(
|
|
value="LOW",
|
|
label="Low",
|
|
description="Low priority - can be handled in regular workflow",
|
|
metadata={
|
|
"color": "green",
|
|
"icon": "arrow-down",
|
|
"css_class": "bg-green-100 text-green-800 border-green-200",
|
|
"sort_order": 1,
|
|
"sla_hours": 168, # 7 days
|
|
"escalation_threshold": 240, # 10 days
|
|
"urgency_level": 1,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="MEDIUM",
|
|
label="Medium",
|
|
description="Medium priority - standard response time expected",
|
|
metadata={
|
|
"color": "yellow",
|
|
"icon": "minus",
|
|
"css_class": "bg-yellow-100 text-yellow-800 border-yellow-200",
|
|
"sort_order": 2,
|
|
"sla_hours": 72, # 3 days
|
|
"escalation_threshold": 120, # 5 days
|
|
"urgency_level": 2,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="HIGH",
|
|
label="High",
|
|
description="High priority - requires prompt attention",
|
|
metadata={
|
|
"color": "orange",
|
|
"icon": "arrow-up",
|
|
"css_class": "bg-orange-100 text-orange-800 border-orange-200",
|
|
"sort_order": 3,
|
|
"sla_hours": 24, # 1 day
|
|
"escalation_threshold": 48, # 2 days
|
|
"urgency_level": 3,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="URGENT",
|
|
label="Urgent",
|
|
description="Urgent priority - immediate attention required",
|
|
metadata={
|
|
"color": "red",
|
|
"icon": "exclamation",
|
|
"css_class": "bg-red-100 text-red-800 border-red-200",
|
|
"sort_order": 4,
|
|
"sla_hours": 4, # 4 hours
|
|
"escalation_threshold": 8, # 8 hours
|
|
"urgency_level": 4,
|
|
"requires_immediate_notification": True,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
]
|
|
|
|
REPORT_TYPES = [
|
|
RichChoice(
|
|
value="SPAM",
|
|
label="Spam",
|
|
description="Unwanted or repetitive content",
|
|
metadata={
|
|
"color": "yellow",
|
|
"icon": "ban",
|
|
"css_class": "bg-yellow-100 text-yellow-800 border-yellow-200",
|
|
"sort_order": 1,
|
|
"default_priority": "MEDIUM",
|
|
"auto_actions": ["content_review"],
|
|
"severity_level": 2,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="HARASSMENT",
|
|
label="Harassment",
|
|
description="Targeted harassment or bullying behavior",
|
|
metadata={
|
|
"color": "red",
|
|
"icon": "shield-exclamation",
|
|
"css_class": "bg-red-100 text-red-800 border-red-200",
|
|
"sort_order": 2,
|
|
"default_priority": "HIGH",
|
|
"auto_actions": ["user_review", "content_review"],
|
|
"severity_level": 4,
|
|
"requires_user_action": True,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="INAPPROPRIATE_CONTENT",
|
|
label="Inappropriate Content",
|
|
description="Content that violates community guidelines",
|
|
metadata={
|
|
"color": "orange",
|
|
"icon": "exclamation-triangle",
|
|
"css_class": "bg-orange-100 text-orange-800 border-orange-200",
|
|
"sort_order": 3,
|
|
"default_priority": "HIGH",
|
|
"auto_actions": ["content_review"],
|
|
"severity_level": 3,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="MISINFORMATION",
|
|
label="Misinformation",
|
|
description="False or misleading information",
|
|
metadata={
|
|
"color": "purple",
|
|
"icon": "information-circle",
|
|
"css_class": "bg-purple-100 text-purple-800 border-purple-200",
|
|
"sort_order": 4,
|
|
"default_priority": "HIGH",
|
|
"auto_actions": ["content_review", "fact_check"],
|
|
"severity_level": 3,
|
|
"requires_expert_review": True,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="COPYRIGHT",
|
|
label="Copyright Violation",
|
|
description="Unauthorized use of copyrighted material",
|
|
metadata={
|
|
"color": "indigo",
|
|
"icon": "document-duplicate",
|
|
"css_class": "bg-indigo-100 text-indigo-800 border-indigo-200",
|
|
"sort_order": 5,
|
|
"default_priority": "HIGH",
|
|
"auto_actions": ["content_review", "legal_review"],
|
|
"severity_level": 4,
|
|
"requires_legal_review": True,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="PRIVACY",
|
|
label="Privacy Violation",
|
|
description="Unauthorized sharing of private information",
|
|
metadata={
|
|
"color": "pink",
|
|
"icon": "lock-closed",
|
|
"css_class": "bg-pink-100 text-pink-800 border-pink-200",
|
|
"sort_order": 6,
|
|
"default_priority": "URGENT",
|
|
"auto_actions": ["content_removal", "user_review"],
|
|
"severity_level": 5,
|
|
"requires_immediate_action": True,
|
|
},
|
|
category=ChoiceCategory.SECURITY,
|
|
),
|
|
RichChoice(
|
|
value="HATE_SPEECH",
|
|
label="Hate Speech",
|
|
description="Content promoting hatred or discrimination",
|
|
metadata={
|
|
"color": "red",
|
|
"icon": "fire",
|
|
"css_class": "bg-red-100 text-red-800 border-red-200",
|
|
"sort_order": 7,
|
|
"default_priority": "URGENT",
|
|
"auto_actions": ["content_removal", "user_suspension"],
|
|
"severity_level": 5,
|
|
"requires_immediate_action": True,
|
|
"zero_tolerance": True,
|
|
},
|
|
category=ChoiceCategory.SECURITY,
|
|
),
|
|
RichChoice(
|
|
value="VIOLENCE",
|
|
label="Violence or Threats",
|
|
description="Content containing violence or threatening behavior",
|
|
metadata={
|
|
"color": "red",
|
|
"icon": "exclamation",
|
|
"css_class": "bg-red-100 text-red-800 border-red-200",
|
|
"sort_order": 8,
|
|
"default_priority": "URGENT",
|
|
"auto_actions": ["content_removal", "user_ban", "law_enforcement_notification"],
|
|
"severity_level": 5,
|
|
"requires_immediate_action": True,
|
|
"zero_tolerance": True,
|
|
"requires_law_enforcement": True,
|
|
},
|
|
category=ChoiceCategory.SECURITY,
|
|
),
|
|
RichChoice(
|
|
value="OTHER",
|
|
label="Other",
|
|
description="Other issues not covered by specific categories",
|
|
metadata={
|
|
"color": "gray",
|
|
"icon": "dots-horizontal",
|
|
"css_class": "bg-gray-100 text-gray-800 border-gray-200",
|
|
"sort_order": 9,
|
|
"default_priority": "MEDIUM",
|
|
"auto_actions": ["manual_review"],
|
|
"severity_level": 1,
|
|
"requires_manual_categorization": True,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
]
|
|
|
|
# ============================================================================
|
|
# ModerationQueue Choices
|
|
# ============================================================================
|
|
|
|
MODERATION_QUEUE_STATUSES = [
|
|
RichChoice(
|
|
value="PENDING",
|
|
label="Pending",
|
|
description="Queue item awaiting assignment or action",
|
|
metadata={
|
|
"color": "yellow",
|
|
"icon": "clock",
|
|
"css_class": "bg-yellow-100 text-yellow-800 border-yellow-200",
|
|
"sort_order": 1,
|
|
"can_transition_to": ["IN_PROGRESS", "CANCELLED"],
|
|
"requires_assignment": False,
|
|
"is_actionable": True,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
RichChoice(
|
|
value="IN_PROGRESS",
|
|
label="In Progress",
|
|
description="Queue item is actively being worked on",
|
|
metadata={
|
|
"color": "blue",
|
|
"icon": "play",
|
|
"css_class": "bg-blue-100 text-blue-800 border-blue-200",
|
|
"sort_order": 2,
|
|
"can_transition_to": ["COMPLETED", "CANCELLED"],
|
|
"requires_assignment": True,
|
|
"is_actionable": True,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
RichChoice(
|
|
value="COMPLETED",
|
|
label="Completed",
|
|
description="Queue item has been successfully completed",
|
|
metadata={
|
|
"color": "green",
|
|
"icon": "check-circle",
|
|
"css_class": "bg-green-100 text-green-800 border-green-200",
|
|
"sort_order": 3,
|
|
"can_transition_to": [],
|
|
"requires_assignment": True,
|
|
"is_actionable": False,
|
|
"is_final": True,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
RichChoice(
|
|
value="CANCELLED",
|
|
label="Cancelled",
|
|
description="Queue item was cancelled and will not be completed",
|
|
metadata={
|
|
"color": "gray",
|
|
"icon": "x-circle",
|
|
"css_class": "bg-gray-100 text-gray-800 border-gray-200",
|
|
"sort_order": 4,
|
|
"can_transition_to": [],
|
|
"requires_assignment": False,
|
|
"is_actionable": False,
|
|
"is_final": True,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
]
|
|
|
|
QUEUE_ITEM_TYPES = [
|
|
RichChoice(
|
|
value="CONTENT_REVIEW",
|
|
label="Content Review",
|
|
description="Review of user-submitted content for policy compliance",
|
|
metadata={
|
|
"color": "blue",
|
|
"icon": "document-text",
|
|
"css_class": "bg-blue-100 text-blue-800 border-blue-200",
|
|
"sort_order": 1,
|
|
"estimated_time_minutes": 15,
|
|
"required_permissions": ["content_moderation"],
|
|
"complexity_level": "medium",
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="USER_REVIEW",
|
|
label="User Review",
|
|
description="Review of user account or behavior",
|
|
metadata={
|
|
"color": "purple",
|
|
"icon": "user",
|
|
"css_class": "bg-purple-100 text-purple-800 border-purple-200",
|
|
"sort_order": 2,
|
|
"estimated_time_minutes": 30,
|
|
"required_permissions": ["user_moderation"],
|
|
"complexity_level": "high",
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="BULK_ACTION",
|
|
label="Bulk Action",
|
|
description="Large-scale administrative operation",
|
|
metadata={
|
|
"color": "indigo",
|
|
"icon": "collection",
|
|
"css_class": "bg-indigo-100 text-indigo-800 border-indigo-200",
|
|
"sort_order": 3,
|
|
"estimated_time_minutes": 60,
|
|
"required_permissions": ["bulk_operations"],
|
|
"complexity_level": "high",
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="POLICY_VIOLATION",
|
|
label="Policy Violation",
|
|
description="Investigation of potential policy violations",
|
|
metadata={
|
|
"color": "red",
|
|
"icon": "shield-exclamation",
|
|
"css_class": "bg-red-100 text-red-800 border-red-200",
|
|
"sort_order": 4,
|
|
"estimated_time_minutes": 45,
|
|
"required_permissions": ["policy_enforcement"],
|
|
"complexity_level": "high",
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="APPEAL",
|
|
label="Appeal",
|
|
description="Review of user appeal against moderation action",
|
|
metadata={
|
|
"color": "orange",
|
|
"icon": "scale",
|
|
"css_class": "bg-orange-100 text-orange-800 border-orange-200",
|
|
"sort_order": 5,
|
|
"estimated_time_minutes": 30,
|
|
"required_permissions": ["appeal_review"],
|
|
"complexity_level": "high",
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="OTHER",
|
|
label="Other",
|
|
description="Other moderation tasks not covered by specific types",
|
|
metadata={
|
|
"color": "gray",
|
|
"icon": "dots-horizontal",
|
|
"css_class": "bg-gray-100 text-gray-800 border-gray-200",
|
|
"sort_order": 6,
|
|
"estimated_time_minutes": 20,
|
|
"required_permissions": ["general_moderation"],
|
|
"complexity_level": "medium",
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
]
|
|
|
|
# ============================================================================
|
|
# ModerationAction Choices
|
|
# ============================================================================
|
|
|
|
MODERATION_ACTION_TYPES = [
|
|
RichChoice(
|
|
value="WARNING",
|
|
label="Warning",
|
|
description="Formal warning issued to user",
|
|
metadata={
|
|
"color": "yellow",
|
|
"icon": "exclamation-triangle",
|
|
"css_class": "bg-yellow-100 text-yellow-800 border-yellow-200",
|
|
"sort_order": 1,
|
|
"severity_level": 1,
|
|
"is_temporary": False,
|
|
"affects_privileges": False,
|
|
"escalation_path": ["USER_SUSPENSION"],
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="USER_SUSPENSION",
|
|
label="User Suspension",
|
|
description="Temporary suspension of user account",
|
|
metadata={
|
|
"color": "orange",
|
|
"icon": "pause",
|
|
"css_class": "bg-orange-100 text-orange-800 border-orange-200",
|
|
"sort_order": 2,
|
|
"severity_level": 3,
|
|
"is_temporary": True,
|
|
"affects_privileges": True,
|
|
"requires_duration": True,
|
|
"escalation_path": ["USER_BAN"],
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="USER_BAN",
|
|
label="User Ban",
|
|
description="Permanent ban of user account",
|
|
metadata={
|
|
"color": "red",
|
|
"icon": "ban",
|
|
"css_class": "bg-red-100 text-red-800 border-red-200",
|
|
"sort_order": 3,
|
|
"severity_level": 5,
|
|
"is_temporary": False,
|
|
"affects_privileges": True,
|
|
"is_permanent": True,
|
|
"requires_admin_approval": True,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="CONTENT_REMOVAL",
|
|
label="Content Removal",
|
|
description="Removal of specific content",
|
|
metadata={
|
|
"color": "red",
|
|
"icon": "trash",
|
|
"css_class": "bg-red-100 text-red-800 border-red-200",
|
|
"sort_order": 4,
|
|
"severity_level": 2,
|
|
"is_temporary": False,
|
|
"affects_privileges": False,
|
|
"is_content_action": True,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="CONTENT_EDIT",
|
|
label="Content Edit",
|
|
description="Modification of content to comply with policies",
|
|
metadata={
|
|
"color": "blue",
|
|
"icon": "pencil",
|
|
"css_class": "bg-blue-100 text-blue-800 border-blue-200",
|
|
"sort_order": 5,
|
|
"severity_level": 1,
|
|
"is_temporary": False,
|
|
"affects_privileges": False,
|
|
"is_content_action": True,
|
|
"preserves_content": True,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="CONTENT_RESTRICTION",
|
|
label="Content Restriction",
|
|
description="Restriction of content visibility or access",
|
|
metadata={
|
|
"color": "purple",
|
|
"icon": "eye-off",
|
|
"css_class": "bg-purple-100 text-purple-800 border-purple-200",
|
|
"sort_order": 6,
|
|
"severity_level": 2,
|
|
"is_temporary": True,
|
|
"affects_privileges": False,
|
|
"is_content_action": True,
|
|
"requires_duration": True,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="ACCOUNT_RESTRICTION",
|
|
label="Account Restriction",
|
|
description="Restriction of specific account privileges",
|
|
metadata={
|
|
"color": "indigo",
|
|
"icon": "lock-closed",
|
|
"css_class": "bg-indigo-100 text-indigo-800 border-indigo-200",
|
|
"sort_order": 7,
|
|
"severity_level": 3,
|
|
"is_temporary": True,
|
|
"affects_privileges": True,
|
|
"requires_duration": True,
|
|
"escalation_path": ["USER_SUSPENSION"],
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="OTHER",
|
|
label="Other",
|
|
description="Other moderation actions not covered by specific types",
|
|
metadata={
|
|
"color": "gray",
|
|
"icon": "dots-horizontal",
|
|
"css_class": "bg-gray-100 text-gray-800 border-gray-200",
|
|
"sort_order": 8,
|
|
"severity_level": 1,
|
|
"is_temporary": False,
|
|
"affects_privileges": False,
|
|
"requires_manual_review": True,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
]
|
|
|
|
# ============================================================================
|
|
# BulkOperation Choices
|
|
# ============================================================================
|
|
|
|
BULK_OPERATION_STATUSES = [
|
|
RichChoice(
|
|
value="PENDING",
|
|
label="Pending",
|
|
description="Operation is queued and waiting to start",
|
|
metadata={
|
|
"color": "yellow",
|
|
"icon": "clock",
|
|
"css_class": "bg-yellow-100 text-yellow-800 border-yellow-200",
|
|
"sort_order": 1,
|
|
"can_transition_to": ["RUNNING", "CANCELLED"],
|
|
"is_actionable": True,
|
|
"can_cancel": True,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
RichChoice(
|
|
value="RUNNING",
|
|
label="Running",
|
|
description="Operation is currently executing",
|
|
metadata={
|
|
"color": "blue",
|
|
"icon": "play",
|
|
"css_class": "bg-blue-100 text-blue-800 border-blue-200",
|
|
"sort_order": 2,
|
|
"can_transition_to": ["COMPLETED", "FAILED", "CANCELLED"],
|
|
"is_actionable": True,
|
|
"can_cancel": True,
|
|
"shows_progress": True,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
RichChoice(
|
|
value="COMPLETED",
|
|
label="Completed",
|
|
description="Operation completed successfully",
|
|
metadata={
|
|
"color": "green",
|
|
"icon": "check-circle",
|
|
"css_class": "bg-green-100 text-green-800 border-green-200",
|
|
"sort_order": 3,
|
|
"can_transition_to": [],
|
|
"is_actionable": False,
|
|
"can_cancel": False,
|
|
"is_final": True,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
RichChoice(
|
|
value="FAILED",
|
|
label="Failed",
|
|
description="Operation failed with errors",
|
|
metadata={
|
|
"color": "red",
|
|
"icon": "x-circle",
|
|
"css_class": "bg-red-100 text-red-800 border-red-200",
|
|
"sort_order": 4,
|
|
"can_transition_to": [],
|
|
"is_actionable": False,
|
|
"can_cancel": False,
|
|
"is_final": True,
|
|
"requires_investigation": True,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
RichChoice(
|
|
value="CANCELLED",
|
|
label="Cancelled",
|
|
description="Operation was cancelled before completion",
|
|
metadata={
|
|
"color": "gray",
|
|
"icon": "stop",
|
|
"css_class": "bg-gray-100 text-gray-800 border-gray-200",
|
|
"sort_order": 5,
|
|
"can_transition_to": [],
|
|
"is_actionable": False,
|
|
"can_cancel": False,
|
|
"is_final": True,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
]
|
|
|
|
BULK_OPERATION_TYPES = [
|
|
RichChoice(
|
|
value="UPDATE_PARKS",
|
|
label="Update Parks",
|
|
description="Bulk update operations on park data",
|
|
metadata={
|
|
"color": "green",
|
|
"icon": "map",
|
|
"css_class": "bg-green-100 text-green-800 border-green-200",
|
|
"sort_order": 1,
|
|
"estimated_duration_minutes": 30,
|
|
"required_permissions": ["bulk_park_operations"],
|
|
"affects_data": ["parks"],
|
|
"risk_level": "medium",
|
|
},
|
|
category=ChoiceCategory.TECHNICAL,
|
|
),
|
|
RichChoice(
|
|
value="UPDATE_RIDES",
|
|
label="Update Rides",
|
|
description="Bulk update operations on ride data",
|
|
metadata={
|
|
"color": "blue",
|
|
"icon": "cog",
|
|
"css_class": "bg-blue-100 text-blue-800 border-blue-200",
|
|
"sort_order": 2,
|
|
"estimated_duration_minutes": 45,
|
|
"required_permissions": ["bulk_ride_operations"],
|
|
"affects_data": ["rides"],
|
|
"risk_level": "medium",
|
|
},
|
|
category=ChoiceCategory.TECHNICAL,
|
|
),
|
|
RichChoice(
|
|
value="IMPORT_DATA",
|
|
label="Import Data",
|
|
description="Import data from external sources",
|
|
metadata={
|
|
"color": "purple",
|
|
"icon": "download",
|
|
"css_class": "bg-purple-100 text-purple-800 border-purple-200",
|
|
"sort_order": 3,
|
|
"estimated_duration_minutes": 60,
|
|
"required_permissions": ["data_import"],
|
|
"affects_data": ["parks", "rides", "users"],
|
|
"risk_level": "high",
|
|
},
|
|
category=ChoiceCategory.TECHNICAL,
|
|
),
|
|
RichChoice(
|
|
value="EXPORT_DATA",
|
|
label="Export Data",
|
|
description="Export data for backup or analysis",
|
|
metadata={
|
|
"color": "indigo",
|
|
"icon": "upload",
|
|
"css_class": "bg-indigo-100 text-indigo-800 border-indigo-200",
|
|
"sort_order": 4,
|
|
"estimated_duration_minutes": 20,
|
|
"required_permissions": ["data_export"],
|
|
"affects_data": [],
|
|
"risk_level": "low",
|
|
},
|
|
category=ChoiceCategory.TECHNICAL,
|
|
),
|
|
RichChoice(
|
|
value="MODERATE_CONTENT",
|
|
label="Moderate Content",
|
|
description="Bulk moderation actions on content",
|
|
metadata={
|
|
"color": "orange",
|
|
"icon": "shield-check",
|
|
"css_class": "bg-orange-100 text-orange-800 border-orange-200",
|
|
"sort_order": 5,
|
|
"estimated_duration_minutes": 40,
|
|
"required_permissions": ["bulk_moderation"],
|
|
"affects_data": ["content", "users"],
|
|
"risk_level": "high",
|
|
},
|
|
category=ChoiceCategory.TECHNICAL,
|
|
),
|
|
RichChoice(
|
|
value="USER_ACTIONS",
|
|
label="User Actions",
|
|
description="Bulk actions on user accounts",
|
|
metadata={
|
|
"color": "red",
|
|
"icon": "users",
|
|
"css_class": "bg-red-100 text-red-800 border-red-200",
|
|
"sort_order": 6,
|
|
"estimated_duration_minutes": 50,
|
|
"required_permissions": ["bulk_user_operations"],
|
|
"affects_data": ["users"],
|
|
"risk_level": "high",
|
|
},
|
|
category=ChoiceCategory.TECHNICAL,
|
|
),
|
|
RichChoice(
|
|
value="CLEANUP",
|
|
label="Cleanup",
|
|
description="System cleanup and maintenance operations",
|
|
metadata={
|
|
"color": "gray",
|
|
"icon": "trash",
|
|
"css_class": "bg-gray-100 text-gray-800 border-gray-200",
|
|
"sort_order": 7,
|
|
"estimated_duration_minutes": 25,
|
|
"required_permissions": ["system_maintenance"],
|
|
"affects_data": ["system"],
|
|
"risk_level": "low",
|
|
},
|
|
category=ChoiceCategory.TECHNICAL,
|
|
),
|
|
RichChoice(
|
|
value="OTHER",
|
|
label="Other",
|
|
description="Other bulk operations not covered by specific types",
|
|
metadata={
|
|
"color": "gray",
|
|
"icon": "dots-horizontal",
|
|
"css_class": "bg-gray-100 text-gray-800 border-gray-200",
|
|
"sort_order": 8,
|
|
"estimated_duration_minutes": 30,
|
|
"required_permissions": ["general_operations"],
|
|
"affects_data": [],
|
|
"risk_level": "medium",
|
|
},
|
|
category=ChoiceCategory.TECHNICAL,
|
|
),
|
|
]
|
|
|
|
# ============================================================================
|
|
# PhotoSubmission Choices (Shared with EditSubmission)
|
|
# ============================================================================
|
|
|
|
# PhotoSubmission uses the same STATUS_CHOICES as EditSubmission
|
|
PHOTO_SUBMISSION_STATUSES = EDIT_SUBMISSION_STATUSES
|
|
|
|
# ============================================================================
|
|
# ModerationAuditLog Action Choices
|
|
# ============================================================================
|
|
|
|
MODERATION_AUDIT_ACTIONS = [
|
|
RichChoice(
|
|
value="approved",
|
|
label="Approved",
|
|
description="Submission was approved by moderator",
|
|
metadata={
|
|
"color": "green",
|
|
"icon": "check-circle",
|
|
"css_class": "bg-green-100 text-green-800",
|
|
"sort_order": 1,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="rejected",
|
|
label="Rejected",
|
|
description="Submission was rejected by moderator",
|
|
metadata={
|
|
"color": "red",
|
|
"icon": "x-circle",
|
|
"css_class": "bg-red-100 text-red-800",
|
|
"sort_order": 2,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="claimed",
|
|
label="Claimed",
|
|
description="Submission was claimed by moderator",
|
|
metadata={
|
|
"color": "blue",
|
|
"icon": "user-check",
|
|
"css_class": "bg-blue-100 text-blue-800",
|
|
"sort_order": 3,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="unclaimed",
|
|
label="Unclaimed",
|
|
description="Submission was released by moderator",
|
|
metadata={
|
|
"color": "gray",
|
|
"icon": "user-minus",
|
|
"css_class": "bg-gray-100 text-gray-800",
|
|
"sort_order": 4,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="escalated",
|
|
label="Escalated",
|
|
description="Submission was escalated for higher-level review",
|
|
metadata={
|
|
"color": "purple",
|
|
"icon": "arrow-up",
|
|
"css_class": "bg-purple-100 text-purple-800",
|
|
"sort_order": 5,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="converted_to_edit",
|
|
label="Converted to Edit",
|
|
description="Photo submission was converted to an edit submission",
|
|
metadata={
|
|
"color": "indigo",
|
|
"icon": "refresh",
|
|
"css_class": "bg-indigo-100 text-indigo-800",
|
|
"sort_order": 6,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="status_changed",
|
|
label="Status Changed",
|
|
description="Submission status was changed",
|
|
metadata={
|
|
"color": "yellow",
|
|
"icon": "refresh-cw",
|
|
"css_class": "bg-yellow-100 text-yellow-800",
|
|
"sort_order": 7,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="notes_added",
|
|
label="Notes Added",
|
|
description="Moderator notes were added to submission",
|
|
metadata={
|
|
"color": "blue",
|
|
"icon": "edit",
|
|
"css_class": "bg-blue-100 text-blue-800",
|
|
"sort_order": 8,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="auto_approved",
|
|
label="Auto Approved",
|
|
description="Submission was auto-approved by the system",
|
|
metadata={
|
|
"color": "green",
|
|
"icon": "zap",
|
|
"css_class": "bg-green-100 text-green-800",
|
|
"sort_order": 9,
|
|
"is_system_action": True,
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
]
|
|
|
|
# ============================================================================
|
|
# Choice Registration
|
|
# ============================================================================
|
|
|
|
# Register all choice groups with the global registry
|
|
register_choices("edit_submission_statuses", EDIT_SUBMISSION_STATUSES, "moderation", "Edit submission status options")
|
|
register_choices("submission_types", SUBMISSION_TYPES, "moderation", "Submission type classifications")
|
|
register_choices(
|
|
"moderation_report_statuses", MODERATION_REPORT_STATUSES, "moderation", "Moderation report status options"
|
|
)
|
|
register_choices("priority_levels", PRIORITY_LEVELS, "moderation", "Priority level classifications")
|
|
register_choices("report_types", REPORT_TYPES, "moderation", "Report type classifications")
|
|
register_choices(
|
|
"moderation_queue_statuses", MODERATION_QUEUE_STATUSES, "moderation", "Moderation queue status options"
|
|
)
|
|
register_choices("queue_item_types", QUEUE_ITEM_TYPES, "moderation", "Queue item type classifications")
|
|
register_choices(
|
|
"moderation_action_types", MODERATION_ACTION_TYPES, "moderation", "Moderation action type classifications"
|
|
)
|
|
register_choices("bulk_operation_statuses", BULK_OPERATION_STATUSES, "moderation", "Bulk operation status options")
|
|
register_choices("bulk_operation_types", BULK_OPERATION_TYPES, "moderation", "Bulk operation type classifications")
|
|
register_choices(
|
|
"photo_submission_statuses", PHOTO_SUBMISSION_STATUSES, "moderation", "Photo submission status options"
|
|
)
|
|
register_choices(
|
|
"moderation_audit_actions", MODERATION_AUDIT_ACTIONS, "moderation", "Moderation audit log action types"
|
|
)
|