Skip to content

Commit

Permalink
admin action to make multiple items public
Browse files Browse the repository at this point in the history
  • Loading branch information
benabraham committed Aug 9, 2023
1 parent 4a0143e commit d6caf02
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions program/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ def create_pretalx_sync() -> pretalx_sync.PretalxSync:
return pretalx_sync.PretalxSync(client)


@admin.action(description="Make public")
def make_public(self, request, queryset):
queryset.update(is_public=True)
self.message_user(request, f"Selected items have been made public.")


@admin.action(description="Update from pretalx")
def speaker_update_from_pretalx(modeladmin, request, queryset):
sync = create_pretalx_sync()
Expand All @@ -32,7 +38,7 @@ class SpeakerAdmin(admin.ModelAdmin):
"linkedin",
"personal_website",
]
actions = [speaker_update_from_pretalx]
actions = [make_public, speaker_update_from_pretalx]


@admin.action(description="Update from pretalx")
Expand All @@ -41,6 +47,7 @@ def talk_update_from_pretalx(modeladmin, request, queryset):
with transaction.atomic():
sync.update_talks(queryset)


@admin.register(Talk)
class TalkAdmin(admin.ModelAdmin):
list_display = [
Expand All @@ -67,7 +74,7 @@ class TalkAdmin(admin.ModelAdmin):
"minimum_topic_knowledge",
"type",
]
actions = [talk_update_from_pretalx]
actions = [make_public, talk_update_from_pretalx]

def get_queryset(self, request):
qs = super().get_queryset(request)
Expand Down Expand Up @@ -110,7 +117,7 @@ class WorkshopAdmin(admin.ModelAdmin):
"minimum_topic_knowledge",
"type",
]
actions = [workshop_update_from_pretalx]
actions = [make_public, workshop_update_from_pretalx]

def get_queryset(self, request):
qs = super().get_queryset(request)
Expand Down

0 comments on commit d6caf02

Please sign in to comment.