import csv import struct from django.db.models import Count from django.http import HttpRequest, HttpResponse from ninja import Router from ninja.decorators import decorate_view from ninja.security import django_auth_is_staff from games.decorators import require_game_enabled from .canvas import read_canvas from .gif import build_evolution_gif from .heatmap import ( build_heatmap_decay_gif, build_heatmap_evolution_gif, build_heatmap_png, ) from .models import PixelPlacement, PlaceSettings router = Router() PREFIX = "/events/{event_path}/place" # 4-byte little-endian header (uint16 width, uint16 height) prefixed to the # canvas payload - the grid can be resized by an admin, so the frontend # can't hardcode dimensions and needs to read them off the payload itself. HEADER_FORMAT = "