Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

announcement action to start today

  • Loading branch information...
commit 403b0b9ac1ced28c78cca03b418deca0b7dd5990 1 parent 62c8921
@dougalsutherland dougalsutherland authored
Showing with 10 additions and 1 deletion.
  1. +10 −1 gazjango/announcements/admin.py
View
11 gazjango/announcements/admin.py
@@ -1,5 +1,6 @@
from django.contrib import admin
from gazjango.announcements.models import Announcement, Poster
+import datetime
class AnnouncementAdmin(admin.ModelAdmin):
list_display = ('slug', 'title', 'unlinked_excerpt', 'is_published',
@@ -9,7 +10,7 @@ class AnnouncementAdmin(admin.ModelAdmin):
date_hierarchy = 'date_start'
save_as = True
- actions = ['make_published']
+ actions = ['make_published', 'start_today']
def make_published(self, request, queryset):
rows_updated = queryset.update(is_published=True)
@@ -20,6 +21,14 @@ def make_published(self, request, queryset):
self.message_user(request, "%s successfully marked as published." % message_bit)
make_published.short_description = "Mark announcements as published"
+ def start_today(self, request, queryset):
+ rows_updated = queryset.update(date_start=datetime.date.today())
+ if rows_updated == 1:
+ message_bit = "1 announcement was"
+ else:
+ message_bit = "%s announcements were" % rows_updated
+ self.message_user(request, "%s successfully set to start today." % message_bit)
+ make_published.short_description = "Set announcements' start date to today"
admin.site.register(Announcement, AnnouncementAdmin)
Please sign in to comment.
Something went wrong with that request. Please try again.