Skip to content

Commit

Permalink
feat: added a little convenience admin action to set all selected tea…
Browse files Browse the repository at this point in the history
…ms as inactive and likewise for active
  • Loading branch information
JasonLovesDoggo committed Dec 21, 2022
1 parent 8266ab1 commit 88edf27
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions scavenger2022/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,26 @@ class LogicPuzzleAdmin(admin.ModelAdmin):
ordering = ("qr_index",)


@admin.action(description="Mark selected teams as inactive")
def set_inactive(modeladmin, request, queryset):
if request.user.is_superuser:
queryset.update(is_active=False)


@admin.action(description="Mark selected teams as active")
def set_active(
modeladmin, request, queryset
): # note you could probably remove this one.
if request.user.is_superuser:
queryset.update(is_active=True)


class TeamAdmin(admin.ModelAdmin):
readonly_fields = ("path",)
inlines = [
InviteInLine,
]
actions = [set_inactive, set_active]

@admin.display(description="Path")
def path(self, team):
Expand Down

0 comments on commit 88edf27

Please sign in to comment.