feat(submissions): scoped submissions per user/matchs, sync from polylan

This commit is contained in:
2026-09-16 13:12:22 +02:00
parent 85e67599af
commit fabf06e6d4
35 changed files with 1008 additions and 92 deletions
+27 -2
View File
@@ -1,4 +1,6 @@
from django.contrib import admin
from django.contrib import admin, messages
from submissions.tasks import sync_event_game_scopes_task
from .models import EventGame, Game
@@ -18,6 +20,29 @@ class GameAdmin(admin.ModelAdmin):
@admin.register(EventGame)
class EventGameAdmin(admin.ModelAdmin):
list_display = ["game", "event", "enabled"]
list_display = ["game", "event", "enabled", "has_apibot_token"]
list_filter = ["event", "enabled"]
search_fields = ["game__name", "event__name"]
actions = ["sync_scopes"]
@admin.display(description="AAndT token", boolean=True)
def has_apibot_token(self, obj):
return bool(obj.apibot_token)
@admin.action(description="Sync scopes from AAndT for selected EventGames")
def sync_scopes(self, request, queryset):
tokened = queryset.exclude(apibot_token__isnull=True).exclude(apibot_token="")
skipped = queryset.count() - tokened.count()
for event_game in tokened:
sync_event_game_scopes_task.enqueue(event_game.id)
self.message_user(
request, f"Queued scope sync for {tokened.count()} EventGame(s)."
)
if skipped:
self.message_user(
request,
f"Skipped {skipped} EventGame(s) with no AAndT token configured.",
level=messages.WARNING,
)
@@ -0,0 +1,23 @@
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("games", "0006_remove_game_enabled"),
]
operations = [
migrations.AddField(
model_name="eventgame",
name="apibot_token",
field=models.CharField(
blank=True,
help_text=(
"Bearer token for the legacy PolyLAN AAndT API (from the AAndT's "
"'apibot' admin page), used to auto-sync Scopes and their assigned users."
),
max_length=512,
null=True,
),
),
]
@@ -0,0 +1,17 @@
# Generated by Django 6.0.5 on 2026-09-16 00:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("games", "0007_eventgame_apibot_token"),
]
operations = [
migrations.AddField(
model_name="game",
name="custom_path",
field=models.BooleanField(default=False),
),
]
+11
View File
@@ -12,6 +12,7 @@ class Game(models.Model):
steam_app_id = models.PositiveIntegerField(null=True, blank=True)
name = models.CharField(max_length=255)
path = models.CharField(max_length=100)
custom_path = models.BooleanField(default=False)
image = models.URLField(null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
@@ -41,6 +42,16 @@ class EventGame(models.Model):
)
enabled = models.BooleanField(default=True)
apibot_token = models.CharField(
max_length=512,
blank=True,
null=True,
help_text=(
"Bearer token for the legacy PolyLAN AAndT API (from the AAndT's "
"'apibot' admin page), used to auto-sync Scopes and their assigned users."
),
)
class Meta:
constraints = [
models.UniqueConstraint(
+1
View File
@@ -8,4 +8,5 @@ class GameOut(Schema):
steam_app_id: Optional[int] = None
name: str
path: str
custom_path: bool
image: Optional[str] = None