feat: clock + place games

This commit is contained in:
2026-09-17 01:33:54 +02:00
parent d104480188
commit 6866b45f66
46 changed files with 2043 additions and 10 deletions
+29
View File
@@ -0,0 +1,29 @@
from django.contrib import admin
from django_object_actions import DjangoObjectActions, action
from .canvas import rebuild_canvas_from_history
from .models import PixelPlacement, PlaceSettings
@admin.register(PlaceSettings)
class PlaceSettingsAdmin(DjangoObjectActions, admin.ModelAdmin):
list_display = ("event", "width", "height")
list_editable = ("width", "height")
list_filter = ("event",)
change_actions = ("resync_canvas",)
@action(
label="Resync canvas from DB",
description="Rebuild the live Redis canvas by replaying the full PixelPlacement history",
)
def resync_canvas(self, request, obj):
count = rebuild_canvas_from_history(obj.event, obj.width, obj.height)
self.message_user(
request, f"Canvas resynced from {count} placement(s) at {obj.width}x{obj.height}."
)
@admin.register(PixelPlacement)
class PixelPlacementAdmin(admin.ModelAdmin):
list_display = ("id", "event", "player", "x", "y", "color_index", "placed_at")
list_filter = ("event", "player")