-
-
Notifications
You must be signed in to change notification settings - Fork 672
Expand file tree
/
Copy pathadmin.py
More file actions
32 lines (21 loc) · 977 Bytes
/
admin.py
File metadata and controls
32 lines (21 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""Admin configuration for the blogs app."""
from django.contrib import admin
from django.core.management import call_command
from apps.blogs.models import BlogEntry, Feed, FeedAggregate
@admin.register(BlogEntry)
class BlogEntryAdmin(admin.ModelAdmin):
"""Admin interface for blog entries imported from RSS feeds."""
list_display = ["title", "pub_date"]
date_hierarchy = "pub_date"
actions = ["sync_new_entries"]
@admin.action(description="Sync new blog entries")
def sync_new_entries(self, request, queryset):
"""Trigger the update_blogs management command to sync new entries."""
call_command("update_blogs")
self.message_user(request, "Blog entries updated.")
@admin.register(FeedAggregate)
class FeedAggregateAdmin(admin.ModelAdmin):
"""Admin interface for managing feed aggregates."""
list_display = ["name", "slug", "description"]
prepopulated_fields = {"slug": ("name",)}
admin.site.register(Feed)