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
+66 -5
View File
@@ -1,5 +1,6 @@
from django.contrib import admin
from .models import Submission, SubmissionFile, ImageCrop
from django.urls import reverse
from .models import Submission, SubmissionFile, ImageCrop, Scope
class ImageCropInline(admin.TabularInline):
@@ -37,16 +38,76 @@ class SubmissionFileInline(admin.TabularInline):
return super().get_queryset(request)
@admin.register(Scope)
class ScopeAdmin(admin.ModelAdmin):
list_display = [
"name",
"event_game",
"external_id",
"is_active",
"assigned_user_count",
"synced_at",
"created_at",
]
list_filter = ["is_active", "event_game__event", "event_game__game"]
search_fields = ["name", "external_id", "event_game__game__name"]
readonly_fields = ["id", "created_at", "updated_at", "synced_at"]
filter_horizontal = ["assigned_users"]
autocomplete_fields = ["event_game"]
def get_queryset(self, request):
return (
super()
.get_queryset(request)
.select_related("event_game", "event_game__event", "event_game__game")
.prefetch_related("assigned_users")
)
@admin.display(description="Assigned users")
def assigned_user_count(self, obj):
return obj.assigned_users.count()
def view_on_site(self, obj):
return reverse(
"submissions.view",
kwargs={
"event_path": obj.event_game.event.path,
"game_path": obj.event_game.game.path,
"scope_id": obj.id,
},
)
@admin.register(Submission)
class SubmissionAdmin(admin.ModelAdmin):
list_display = ["id_short", "game", "user", "notes_preview", "created_at"]
list_filter = ["game", "created_at", "updated_at"]
search_fields = ["id", "user__email", "notes", "game__name"]
list_display = ["id_short", "scope", "game", "user", "notes_preview", "created_at"]
list_filter = [
"scope__event_game__game",
"scope__event_game__event",
"created_at",
"updated_at",
]
search_fields = [
"id",
"user__email",
"notes",
"scope__event_game__game__name",
"scope__name",
]
readonly_fields = ["id", "created_at", "updated_at"]
autocomplete_fields = ["scope"]
inlines = [SubmissionFileInline]
def get_queryset(self, request):
return super().get_queryset(request).select_related("user", "game")
return (
super()
.get_queryset(request)
.select_related("user", "scope", "scope__event_game__game")
)
@admin.display(description="Game", ordering="scope__event_game__game")
def game(self, obj):
return obj.scope.event_game.game
@admin.display(description="ID")
def id_short(self, obj):