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