feat(submissions): scoped submissions per user/matchs, sync from polylan
This commit is contained in:
@@ -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,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user