feat: clock + place games
This commit is contained in:
@@ -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")
|
||||
Reference in New Issue
Block a user