mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2026-02-05 02:35:18 -05:00
feat: add security event taxonomy and optimize park queryset - Add comprehensive security_event_types ChoiceGroup with categories for authentication, MFA, password, account, session, and API key events - Include severity levels, icons, and CSS classes for each event type - Fix park queryset optimization by using select_related for OneToOne location relationship - Remove location property fields (latitude/longitude) from values() call as they are not actual DB columns - Add proper location fields (city, state, country) to values() for map display This change enhances security event tracking capabilities and resolves a queryset optimization issue where property decorators were incorrectly used in values() queries.
167 lines
5.1 KiB
Python
167 lines
5.1 KiB
Python
"""
|
|
Rich Choice Objects for Support Domain
|
|
|
|
This module defines all choice objects for the support domain,
|
|
using the RichChoices pattern for consistent UI rendering and validation.
|
|
|
|
Note: Values are kept lowercase for backward compatibility with existing data.
|
|
"""
|
|
|
|
from apps.core.choices import ChoiceCategory, RichChoice
|
|
from apps.core.choices.registry import register_choices
|
|
|
|
# ============================================================================
|
|
# Ticket Status Choices
|
|
# ============================================================================
|
|
|
|
TICKET_STATUSES = [
|
|
RichChoice(
|
|
value="open",
|
|
label="Open",
|
|
description="Ticket is awaiting response",
|
|
metadata={
|
|
"color": "yellow",
|
|
"icon": "inbox",
|
|
"css_class": "bg-yellow-100 text-yellow-800 border-yellow-200",
|
|
"sort_order": 1,
|
|
"can_transition_to": ["in_progress", "closed"],
|
|
"is_actionable": True,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
RichChoice(
|
|
value="in_progress",
|
|
label="In Progress",
|
|
description="Ticket is being worked on",
|
|
metadata={
|
|
"color": "blue",
|
|
"icon": "clock",
|
|
"css_class": "bg-blue-100 text-blue-800 border-blue-200",
|
|
"sort_order": 2,
|
|
"can_transition_to": ["closed"],
|
|
"is_actionable": True,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
RichChoice(
|
|
value="closed",
|
|
label="Closed",
|
|
description="Ticket has been resolved",
|
|
metadata={
|
|
"color": "green",
|
|
"icon": "check-circle",
|
|
"css_class": "bg-green-100 text-green-800 border-green-200",
|
|
"sort_order": 3,
|
|
"can_transition_to": ["open"],
|
|
"is_actionable": False,
|
|
"is_final": True,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
]
|
|
|
|
# ============================================================================
|
|
# Ticket Category Choices
|
|
# ============================================================================
|
|
|
|
TICKET_CATEGORIES = [
|
|
RichChoice(
|
|
value="general",
|
|
label="General Inquiry",
|
|
description="General questions or feedback",
|
|
metadata={
|
|
"color": "gray",
|
|
"icon": "chat-bubble-left",
|
|
"css_class": "bg-gray-100 text-gray-800 border-gray-200",
|
|
"sort_order": 1,
|
|
"default_priority": "low",
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="bug",
|
|
label="Bug Report",
|
|
description="Report a bug or issue with the platform",
|
|
metadata={
|
|
"color": "red",
|
|
"icon": "bug-ant",
|
|
"css_class": "bg-red-100 text-red-800 border-red-200",
|
|
"sort_order": 2,
|
|
"default_priority": "high",
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="partnership",
|
|
label="Partnership",
|
|
description="Partnership or collaboration inquiries",
|
|
metadata={
|
|
"color": "purple",
|
|
"icon": "handshake",
|
|
"css_class": "bg-purple-100 text-purple-800 border-purple-200",
|
|
"sort_order": 3,
|
|
"default_priority": "medium",
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="press",
|
|
label="Press/Media",
|
|
description="Press inquiries and media requests",
|
|
metadata={
|
|
"color": "indigo",
|
|
"icon": "newspaper",
|
|
"css_class": "bg-indigo-100 text-indigo-800 border-indigo-200",
|
|
"sort_order": 4,
|
|
"default_priority": "medium",
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="data",
|
|
label="Data Correction",
|
|
description="Request corrections to park or ride data",
|
|
metadata={
|
|
"color": "orange",
|
|
"icon": "pencil-square",
|
|
"css_class": "bg-orange-100 text-orange-800 border-orange-200",
|
|
"sort_order": 5,
|
|
"default_priority": "medium",
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="account",
|
|
label="Account Issue",
|
|
description="Account-related problems or requests",
|
|
metadata={
|
|
"color": "cyan",
|
|
"icon": "user-circle",
|
|
"css_class": "bg-cyan-100 text-cyan-800 border-cyan-200",
|
|
"sort_order": 6,
|
|
"default_priority": "high",
|
|
},
|
|
category=ChoiceCategory.CLASSIFICATION,
|
|
),
|
|
]
|
|
|
|
|
|
def register_support_choices() -> None:
|
|
"""Register all support domain choices with the global registry."""
|
|
register_choices(
|
|
"ticket_statuses",
|
|
TICKET_STATUSES,
|
|
domain="support",
|
|
description="Status options for support tickets",
|
|
)
|
|
register_choices(
|
|
"ticket_categories",
|
|
TICKET_CATEGORIES,
|
|
domain="support",
|
|
description="Category options for support tickets",
|
|
)
|
|
|
|
|
|
# Auto-register choices when module is imported
|
|
register_support_choices()
|