Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

Commit

Permalink
Merge pull request #356 from aldryn/feature/publish-action
Browse files Browse the repository at this point in the history
toolbar: publish action
  • Loading branch information
Chive committed Mar 23, 2016
2 parents de506da + 24a4b41 commit e7b9949
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
13 changes: 12 additions & 1 deletion aldryn_newsblog/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class ArticleAdmin(
make_featured, make_not_featured,
make_published, make_unpublished,
)
fieldsets = (
_fieldsets = (
(None, {
'fields': (
'title',
Expand Down Expand Up @@ -130,6 +130,13 @@ class ArticleAdmin(
)
}),
)

_publish_fieldsets = (
(None, {
'fields': ('publishing_date', 'is_published')
}),
)

app_config_values = {
'default_published': 'is_published'
}
Expand All @@ -147,6 +154,10 @@ def add_view(self, request, *args, **kwargs):
request.GET = data
return super(ArticleAdmin, self).add_view(request, *args, **kwargs)

def get_fieldsets(self, request, obj=None):
if 'publish' in request.GET:
return self._publish_fieldsets
return self._fieldsets

admin.site.register(models.Article, ArticleAdmin)

Expand Down
18 changes: 16 additions & 2 deletions aldryn_newsblog/cms_toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,22 @@ def populate(self):
url_args = {'language': language, }
url = get_admin_url('aldryn_newsblog_article_change',
[article.pk, ], **url_args)
menu.add_modal_item(_('Edit this article'), url=url,
active=True)
menu.add_modal_item(
_('Edit this article'),
url=url, active=True
)
if article.published:
title = _('Unpublish this article')
else:
title = _('Publish this article')

url_args['publish'] = 1
url = get_admin_url(
'aldryn_newsblog_article_change',
[article.pk, ],
**url_args
)
menu.add_modal_item(title, url=url)

if delete_article_perm and article:
redirect_url = self.get_on_delete_redirect_url(
Expand Down

0 comments on commit e7b9949

Please sign in to comment.