mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2026-02-06 05:05:15 -05:00
feat(state-machine): add comprehensive callback system for transitions
Extend state machine module with callback infrastructure including: - Pre/post/error transition callbacks with registry - Signal-based transition notifications - Callback configuration and monitoring support - Helper functions for callback registration - Improved park ride count updates with FSM integration
This commit is contained in:
@@ -9,6 +9,11 @@ This module contains models for the ThrillWiki moderation system, including:
|
||||
- BulkOperation: Administrative bulk operations
|
||||
|
||||
All models use pghistory for change tracking and TrackedModel base class.
|
||||
|
||||
Callback System Integration:
|
||||
All FSM-enabled models in this module support the callback system.
|
||||
Callbacks for notifications, cache invalidation, and related updates
|
||||
are registered via the callback configuration defined in each model's Meta class.
|
||||
"""
|
||||
|
||||
from typing import Any, Dict, Optional, Union
|
||||
@@ -29,6 +34,35 @@ from apps.core.state_machine import RichFSMField, StateMachineMixin
|
||||
UserType = Union[AbstractBaseUser, AnonymousUser]
|
||||
|
||||
|
||||
# Lazy callback imports to avoid circular dependencies
|
||||
def _get_notification_callbacks():
|
||||
"""Lazy import of notification callbacks."""
|
||||
from apps.core.state_machine.callbacks.notifications import (
|
||||
SubmissionApprovedNotification,
|
||||
SubmissionRejectedNotification,
|
||||
SubmissionEscalatedNotification,
|
||||
ModerationNotificationCallback,
|
||||
)
|
||||
return {
|
||||
'approved': SubmissionApprovedNotification,
|
||||
'rejected': SubmissionRejectedNotification,
|
||||
'escalated': SubmissionEscalatedNotification,
|
||||
'moderation': ModerationNotificationCallback,
|
||||
}
|
||||
|
||||
|
||||
def _get_cache_callbacks():
|
||||
"""Lazy import of cache callbacks."""
|
||||
from apps.core.state_machine.callbacks.cache import (
|
||||
CacheInvalidationCallback,
|
||||
ModerationCacheInvalidation,
|
||||
)
|
||||
return {
|
||||
'generic': CacheInvalidationCallback,
|
||||
'moderation': ModerationCacheInvalidation,
|
||||
}
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Original EditSubmission Model (Preserved)
|
||||
# ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user