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:
1 parent
3d1e820564
commit
eab141f467
24 files changed
+928
-11
No files matched your search
@@ -36,9 +36,19 @@ class LotteryConfig(models.Model):
|
||||
new_bets_suspended = models.BooleanField(default=False)
|
||||
withdrawals_suspended = models.BooleanField(default=False)
|
||||
|
||||
# WEB-31: written by the worker at every tick; the console reads it to tell a live worker from a dead one.
|
||||
worker_seen_at = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
# WEB-30, WEB-44: one explicit permission per operational command, checked in the view and again in the service.
|
||||
permissions = [
|
||||
("view_console", "Can open the operations console"),
|
||||
("pause_after_round", "Can pause the lottery after the round in progress"),
|
||||
("suspend_new_bets", "Can suspend new bets"),
|
||||
("suspend_withdrawals", "Can suspend withdrawals"),
|
||||
]
|
||||
constraints = [
|
||||
models.CheckConstraint(condition=Q(id=1), name="lottery_config_single_row"),
|
||||
models.CheckConstraint(condition=Q(bet_amount_sats__gt=0), name="lottery_config_bet_positive"),
|
||||
@@ -383,3 +393,30 @@ class AuditEntry(models.Model):
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.created_at:%Y-%m-%d %H:%M} {self.actor_label} {self.action}"
|
||||
|
||||
|
||||
class Report(models.Model):
|
||||
"""A problem report written by a player from the profile (WEB-55). Staff reads it and changes its
|
||||
status from the admin; each status change is in the audit."""
|
||||
|
||||
class Status(models.TextChoices):
|
||||
OPEN = "open", "Aperta"
|
||||
READ = "read", "Letta"
|
||||
RESOLVED = "resolved", "Risolta"
|
||||
|
||||
MAX_LENGTH = 1000
|
||||
|
||||
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.PROTECT, related_name="reports")
|
||||
text = models.TextField(max_length=MAX_LENGTH)
|
||||
status = models.CharField(max_length=16, choices=Status.choices, default=Status.OPEN)
|
||||
created_at = models.DateTimeField(default=timezone.now)
|
||||
status_changed_at = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
indexes = [models.Index(fields=["user", "-created_at"]), models.Index(fields=["status"])]
|
||||
constraints = [
|
||||
models.CheckConstraint(condition=Q(status__in=["open", "read", "resolved"]), name="lottery_report_status_valid"),
|
||||
]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"Report {self.pk} ({self.status})"
|
||||
Reference in new issue
Block a user