2016-05-30 19:36:14 +00:00
|
|
|
from django.contrib import admin
|
|
|
|
|
|
|
|
from . import models
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(models.NewsItem)
|
|
|
|
class NewsItemModelAdmin(admin.ModelAdmin):
|
2016-12-25 14:52:55 +00:00
|
|
|
list_display = ['title', 'published_at', 'archived']
|
|
|
|
actions = ['archive_news_items', 'unarchive_news_items']
|
|
|
|
|
|
|
|
def archive_news_items(self, request, queryset):
|
|
|
|
queryset.filter(archived=False).update(archived=True)
|
|
|
|
archive_news_items.description = 'Mark newsitem(s) as archived'
|
|
|
|
|
|
|
|
def unarchive_news_items(self, request, queryset):
|
|
|
|
queryset.filter(archived=True).update(archived=False)
|
|
|
|
unarchive_news_items.description = 'Mark newsitem(s) as not archived'
|
|
|
|
|
|
|
|
|