add action to bulk mark documents as public/hidden
This commit is contained in:
parent
03c13e2238
commit
ae90e25de6
1 changed files with 11 additions and 0 deletions
|
@ -35,11 +35,22 @@ class DocumentAdmin(admin.ModelAdmin):
|
||||||
list_display = ('title', 'author', 'published', 'public', 'filed_under')
|
list_display = ('title', 'author', 'published', 'public', 'filed_under')
|
||||||
list_filter = ('tags', 'public', DocumentExternalListFilter)
|
list_filter = ('tags', 'public', DocumentExternalListFilter)
|
||||||
search_fields = ('title', 'author', 'published')
|
search_fields = ('title', 'author', 'published')
|
||||||
|
actions = ('make_published', 'make_hidden')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def filed_under(document: Document):
|
def filed_under(document: Document):
|
||||||
return ", ".join(tag.name for tag in document.tags.all())
|
return ", ".join(tag.name for tag in document.tags.all())
|
||||||
|
|
||||||
|
def make_published(self, _, queryset):
|
||||||
|
queryset.update(public=True)
|
||||||
|
|
||||||
|
make_published.short_description = "Mark selected articles as public"
|
||||||
|
|
||||||
|
def make_hidden(self, _, queryset):
|
||||||
|
queryset.update(public=False)
|
||||||
|
|
||||||
|
make_hidden.short_description = "Mark selected articles as hidden"
|
||||||
|
|
||||||
|
|
||||||
admin.site.site_title = '/-\\ pile'
|
admin.site.site_title = '/-\\ pile'
|
||||||
admin.site.site_header = '/-\\ pile administration'
|
admin.site.site_header = '/-\\ pile administration'
|
||||||
|
|
Loading…
Reference in a new issue