bornhack-website/src/news/admin.py

20 lines
630 B
Python
Raw Normal View History

2016-05-30 19:36:14 +00:00
from django.contrib import admin
from . import models
@admin.register(models.NewsItem)
class NewsItemModelAdmin(admin.ModelAdmin):
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'