mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-31 05:07:02 -05:00
feat: Implement MFA authentication, add ride statistics model, and update various services, APIs, and tests across the application.
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
import logging
|
||||
|
||||
from django.db.models.signals import pre_save, post_save
|
||||
from django.db.models.signals import post_save, pre_save
|
||||
from django.dispatch import receiver
|
||||
from django.utils import timezone
|
||||
|
||||
from .models import Ride
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -59,16 +58,15 @@ def handle_ride_status(sender, instance, **kwargs):
|
||||
# Check if transition is allowed before attempting
|
||||
if hasattr(instance, 'can_proceed'):
|
||||
can_proceed = getattr(instance, f'can_transition_to_{target_status.lower()}', None)
|
||||
if can_proceed and callable(can_proceed):
|
||||
if not can_proceed():
|
||||
logger.warning(
|
||||
f"FSM transition to {target_status} not allowed "
|
||||
f"for ride {instance.pk}"
|
||||
)
|
||||
# Fall back to direct status change
|
||||
instance.status = target_status
|
||||
instance.status_since = instance.closing_date
|
||||
return
|
||||
if can_proceed and callable(can_proceed) and not can_proceed():
|
||||
logger.warning(
|
||||
f"FSM transition to {target_status} not allowed "
|
||||
f"for ride {instance.pk}"
|
||||
)
|
||||
# Fall back to direct status change
|
||||
instance.status = target_status
|
||||
instance.status_since = instance.closing_date
|
||||
return
|
||||
|
||||
try:
|
||||
method = getattr(instance, transition_method_name)
|
||||
|
||||
Reference in New Issue
Block a user