mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2026-02-05 09:25:18 -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.
186 lines
5.5 KiB
Python
186 lines
5.5 KiB
Python
"""
|
|
Rich Choice Objects for Notifications Domain
|
|
|
|
This module defines all choice objects for the notifications domain,
|
|
using the RichChoices pattern for consistent UI rendering and validation.
|
|
"""
|
|
|
|
from apps.core.choices import ChoiceCategory, RichChoice
|
|
from apps.core.choices.registry import register_choices
|
|
|
|
# ============================================================================
|
|
# Notification Log Status Choices
|
|
# ============================================================================
|
|
NOTIFICATION_LOG_STATUSES = [
|
|
RichChoice(
|
|
value="pending",
|
|
label="Pending",
|
|
description="Notification is queued for delivery",
|
|
metadata={
|
|
"color": "yellow",
|
|
"icon": "clock",
|
|
"css_class": "bg-yellow-100 text-yellow-800",
|
|
"sort_order": 1,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
RichChoice(
|
|
value="sent",
|
|
label="Sent",
|
|
description="Notification has been sent",
|
|
metadata={
|
|
"color": "blue",
|
|
"icon": "send",
|
|
"css_class": "bg-blue-100 text-blue-800",
|
|
"sort_order": 2,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
RichChoice(
|
|
value="delivered",
|
|
label="Delivered",
|
|
description="Notification was successfully delivered",
|
|
metadata={
|
|
"color": "green",
|
|
"icon": "check-circle",
|
|
"css_class": "bg-green-100 text-green-800",
|
|
"sort_order": 3,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
RichChoice(
|
|
value="failed",
|
|
label="Failed",
|
|
description="Notification delivery failed",
|
|
metadata={
|
|
"color": "red",
|
|
"icon": "x-circle",
|
|
"css_class": "bg-red-100 text-red-800",
|
|
"sort_order": 4,
|
|
},
|
|
category=ChoiceCategory.STATUS,
|
|
),
|
|
]
|
|
|
|
# ============================================================================
|
|
# System Announcement Severity Choices
|
|
# ============================================================================
|
|
ANNOUNCEMENT_SEVERITIES = [
|
|
RichChoice(
|
|
value="info",
|
|
label="Information",
|
|
description="Informational announcement",
|
|
metadata={
|
|
"color": "blue",
|
|
"icon": "info",
|
|
"css_class": "bg-blue-100 text-blue-800 border-blue-200",
|
|
"sort_order": 1,
|
|
},
|
|
category=ChoiceCategory.PRIORITY,
|
|
),
|
|
RichChoice(
|
|
value="warning",
|
|
label="Warning",
|
|
description="Warning announcement requiring attention",
|
|
metadata={
|
|
"color": "yellow",
|
|
"icon": "alert-triangle",
|
|
"css_class": "bg-yellow-100 text-yellow-800 border-yellow-200",
|
|
"sort_order": 2,
|
|
},
|
|
category=ChoiceCategory.PRIORITY,
|
|
),
|
|
RichChoice(
|
|
value="critical",
|
|
label="Critical",
|
|
description="Critical announcement requiring immediate attention",
|
|
metadata={
|
|
"color": "red",
|
|
"icon": "alert-octagon",
|
|
"css_class": "bg-red-100 text-red-800 border-red-200",
|
|
"sort_order": 3,
|
|
},
|
|
category=ChoiceCategory.PRIORITY,
|
|
),
|
|
]
|
|
|
|
# ============================================================================
|
|
# Notification Level Choices (for in-app notifications)
|
|
# ============================================================================
|
|
NOTIFICATION_LEVELS = [
|
|
RichChoice(
|
|
value="info",
|
|
label="Info",
|
|
description="Informational notification",
|
|
metadata={
|
|
"color": "blue",
|
|
"icon": "info",
|
|
"css_class": "bg-blue-100 text-blue-800",
|
|
"sort_order": 1,
|
|
},
|
|
category=ChoiceCategory.NOTIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="success",
|
|
label="Success",
|
|
description="Success notification",
|
|
metadata={
|
|
"color": "green",
|
|
"icon": "check-circle",
|
|
"css_class": "bg-green-100 text-green-800",
|
|
"sort_order": 2,
|
|
},
|
|
category=ChoiceCategory.NOTIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="warning",
|
|
label="Warning",
|
|
description="Warning notification",
|
|
metadata={
|
|
"color": "yellow",
|
|
"icon": "alert-triangle",
|
|
"css_class": "bg-yellow-100 text-yellow-800",
|
|
"sort_order": 3,
|
|
},
|
|
category=ChoiceCategory.NOTIFICATION,
|
|
),
|
|
RichChoice(
|
|
value="error",
|
|
label="Error",
|
|
description="Error notification",
|
|
metadata={
|
|
"color": "red",
|
|
"icon": "x-circle",
|
|
"css_class": "bg-red-100 text-red-800",
|
|
"sort_order": 4,
|
|
},
|
|
category=ChoiceCategory.NOTIFICATION,
|
|
),
|
|
]
|
|
|
|
|
|
def register_notifications_choices() -> None:
|
|
"""Register all notifications domain choices with the global registry."""
|
|
register_choices(
|
|
name="notification_log_statuses",
|
|
choices=NOTIFICATION_LOG_STATUSES,
|
|
domain="notifications",
|
|
description="Status options for notification logs",
|
|
)
|
|
register_choices(
|
|
name="announcement_severities",
|
|
choices=ANNOUNCEMENT_SEVERITIES,
|
|
domain="notifications",
|
|
description="Severity levels for system announcements",
|
|
)
|
|
register_choices(
|
|
name="notification_levels",
|
|
choices=NOTIFICATION_LEVELS,
|
|
domain="notifications",
|
|
description="Level options for in-app notifications",
|
|
)
|
|
|
|
|
|
# Auto-register choices when module is imported
|
|
register_notifications_choices()
|