A9: operations console, three pause commands, admin and player reports (WEB-30..32, WEB-40..44, WEB-55, AUD-48)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
davideandClaude Sonnet 5.5 committed 2026-11-16 15:03:22 +01:00
1 parent 3d1e820564
commit eab141f467
24 files changed
+928 -11

No files matched your search

+54 -1
View File
@@ -1,6 +1,59 @@
"""Users in the admin (WEB-32). Staff can deactivate or promote an account but never delete one: a user's
ledger rows are PROTECTed (DAT-76), and a deactivation is an audited action. A user's game records are shown
read-only on the same page."""
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from apps.lottery import audit
from apps.lottery.models import Movement, Participation
from .models import User
admin.site.register(User, UserAdmin)
class ReadOnlyInline(admin.TabularInline):
extra = 0
can_delete = False
show_change_link = False
def has_add_permission(self, request, obj=None):
return False
def has_change_permission(self, request, obj=None):
return False
def has_delete_permission(self, request, obj=None):
return False
class ParticipationInline(ReadOnlyInline):
model = Participation
fields = ("round", "status", "bet_amount_sats", "created_at")
readonly_fields = fields
ordering = ("-id",)
max_num = 0
verbose_name_plural = "Participations (read-only)"
class MovementInline(ReadOnlyInline):
model = Movement
fields = ("kind", "status", "amount_sats", "round", "created_at")
readonly_fields = fields
ordering = ("-id",)
max_num = 0
verbose_name_plural = "Movements (read-only)"
@admin.register(User)
class AccountAdmin(UserAdmin):
inlines = [ParticipationInline, MovementInline]
def has_delete_permission(self, request, obj=None):
return False
def save_model(self, request, obj, form, change):
super().save_model(request, obj, form, change)
if change and {"is_active", "is_staff", "is_superuser"} & set(form.changed_data):
audit.record("user_changed", actor=request.user, subject_type="user", subject_id=obj.pk,
payload={name: getattr(obj, name) for name in ("is_active", "is_staff", "is_superuser")
if name in form.changed_data})