Skip to content

Commit

Permalink
add an admin action for announcements to mark them as published
Browse files Browse the repository at this point in the history
  • Loading branch information
djsutherland committed Mar 17, 2011
1 parent c473b29 commit 62c8921
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions gazjango/announcements/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ class AnnouncementAdmin(admin.ModelAdmin):
search_fields = ('slug', 'title', 'text', 'sponsor')
date_hierarchy = 'date_start'
save_as = True

actions = ['make_published']

def make_published(self, request, queryset):
rows_updated = queryset.update(is_published=True)
if rows_updated == 1:
message_bit = "1 announcement was"
else:
message_bit = "%s announcements were" % rows_updated
self.message_user(request, "%s successfully marked as published." % message_bit)
make_published.short_description = "Mark announcements as published"



admin.site.register(Announcement, AnnouncementAdmin)

class PosterAdmin(admin.ModelAdmin):
Expand Down

0 comments on commit 62c8921

Please sign in to comment.