Based on the git diff provided, here's a concise and descriptive commit message:

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.
This commit is contained in:
pacnpal
2026-01-12 19:13:05 -05:00
parent 2b66814d82
commit d631f3183c
56 changed files with 5860 additions and 264 deletions

View File

@@ -0,0 +1,185 @@
"""
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()