Source

copelco / lib / copelco / apps / aggregator / admin.py

from django.contrib import admin

from copelco.apps.aggregator import models as aggregator
from copelco.apps.aggregator.tasks import UpdateFeed


class FeedAdmin(admin.ModelAdmin):
    list_display = ('title', 'feed_type', 'public_url')
    list_filter = ('feed_type', 'is_defunct')
    ordering = ('title',)
    search_fields = ('title', 'public_url')
    
    def save_model(self, request, obj, form, change):
        obj.save()
        UpdateFeed.delay(feed_id=obj.pk)


class FeedItemAdmin(admin.ModelAdmin):
    list_display = ('id', 'title', 'feed', 'date_modified')
    list_filter = ('date_modified', 'feed',)
    ordering = ('-date_modified',)
    search_fields = ('feed__title', 'feed__public_url', 'title')
    date_heirarchy = ('date_modified',)


admin.site.register(aggregator.Feed, FeedAdmin)
admin.site.register(aggregator.FeedItem, FeedItemAdmin)