feat(place): final end time + destruction wave

This commit is contained in:
2026-10-25 12:55:24 +01:00
parent 1844b973e9
commit 73b279d7fe
14 changed files with 372 additions and 39 deletions
+10 -3
View File
@@ -1,5 +1,4 @@
"""Reacts to an admin editing a PlaceSettings row (grid size, placement
toggle) by:
"""Reacts to an admin editing a PlaceSettings row (grid size, end time) by:
1. Rebuilding that event's Redis canvas from history at the (possibly new)
dimensions - a resize invalidates the old Redis bytes (wrong length,
@@ -9,6 +8,7 @@ toggle) by:
2. Pushing the new settings to that event's already-connected clients. Unlike
the clock app, place has no periodic heartbeat broadcast to piggyback
this onto, so it's broadcast explicitly here instead.
3. Queueing the wipe for the end time, if any (see tasks.py).
"""
from asgiref.sync import async_to_sync
@@ -19,11 +19,14 @@ from django.dispatch import receiver
from .broadcast import place_group
from .canvas import rebuild_canvas_from_history
from .models import PlaceSettings
from .tasks import schedule_wipe
from .wire import to_epoch_ms
@receiver(post_save, sender=PlaceSettings)
def on_settings_saved(sender, instance, **kwargs):
rebuild_canvas_from_history(instance.event, instance.width, instance.height)
schedule_wipe(instance)
channel_layer = get_channel_layer()
if channel_layer is None:
@@ -34,6 +37,10 @@ def on_settings_saved(sender, instance, **kwargs):
"type": "settings_changed",
"width": instance.width,
"height": instance.height,
"placement_enabled": instance.placement_enabled,
"ends_at": (
None
if instance.placement_ends_at is None
else to_epoch_ms(instance.placement_ends_at)
),
},
)