Skip to content

Commit

Permalink
Adapt the admin for publication_date
Browse files Browse the repository at this point in the history
  • Loading branch information
Fantomas42 committed Jul 3, 2015
1 parent a6e9a89 commit 44ffcb1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions zinnia/admin/entry.py
Expand Up @@ -24,16 +24,16 @@ class EntryAdmin(admin.ModelAdmin):
Admin for Entry model.
"""
form = EntryAdminForm
date_hierarchy = 'creation_date'
date_hierarchy = 'publication_date'
fieldsets = (
(_('Content'), {
'fields': (('title', 'status'), 'lead', 'content',)}),
(_('Illustration'), {
'fields': ('image', 'image_caption'),
'classes': ('collapse', 'collapse-closed')}),
(_('Publication'), {
'fields': (('start_publication', 'end_publication'),
'creation_date', 'sites'),
'fields': ('publication_date', 'sites',
('start_publication', 'end_publication')),
'classes': ('collapse', 'collapse-closed')}),
(_('Discussions'), {
'fields': ('comment_enabled', 'pingback_enabled',
Expand All @@ -49,13 +49,11 @@ class EntryAdmin(admin.ModelAdmin):
'fields': ('featured', 'excerpt', 'authors', 'related'),
'classes': ('collapse', 'collapse-closed')}),
(None, {'fields': ('categories', 'tags', 'slug')}))
list_filter = (CategoryListFilter, AuthorListFilter, 'status', 'featured',
'login_required', 'comment_enabled', 'pingback_enabled',
'trackback_enabled', 'creation_date', 'start_publication',
'end_publication', 'sites')
list_filter = (CategoryListFilter, AuthorListFilter,
'publication_date', 'sites', 'status')
list_display = ('get_title', 'get_authors', 'get_categories',
'get_tags', 'get_sites', 'get_is_visible', 'featured',
'get_short_url', 'creation_date')
'get_short_url', 'publication_date')
radio_fields = {'content_template': admin.VERTICAL,
'detail_template': admin.VERTICAL}
filter_horizontal = ('categories', 'authors', 'related')
Expand Down Expand Up @@ -305,7 +303,7 @@ def put_on_top(self, request, queryset):
"""
Put the selected entries on top at the current date.
"""
queryset.update(creation_date=timezone.now())
queryset.update(publication_date=timezone.now())
self.ping_directories(request, queryset, messages=False)
self.message_user(request, _(
'The selected entries are now set at the current date.'))
Expand Down
2 changes: 1 addition & 1 deletion zinnia/tests/test_admin.py
Expand Up @@ -346,7 +346,7 @@ def test_put_on_top(self):
original_ping_directories = settings.PING_DIRECTORIES
settings.PING_DIRECTORIES = []
self.request._messages = TestMessageBackend()
self.entry.creation_date = datetime(2011, 1, 1, 12, 0)
self.entry.publication_date = datetime(2011, 1, 1, 12, 0)
self.admin.put_on_top(self.request, Entry.objects.all())
self.assertEqual(
Entry.objects.get(pk=self.entry.pk).creation_date.date(),
Expand Down

0 comments on commit 44ffcb1

Please sign in to comment.