Improved NewsletterArticleAdmin. Corrected embed templatetag errors related to Consta...
[philo.git] / contrib / penfield / admin.py
index c34199b..c758e67 100644 (file)
@@ -1,11 +1,52 @@
-from models import BlogEntry, Blog
 from django.contrib import admin
-from philo.admin import EntityAdmin
+from philo.admin import EntityAdmin, AddTagAdmin
+from philo.contrib.penfield.models import BlogEntry, Blog, BlogView, Newsletter, NewsletterArticle, NewsletterIssue, NewsletterView
 
-class TitledContentAdmin(EntityAdmin):
+
+class TitledAdmin(EntityAdmin):
        prepopulated_fields = {'slug': ('title',)}
        list_display = ('title', 'slug')
 
 
-admin.site.register(BlogEntry, TitledContentAdmin)
-admin.site.register(Blog)
\ No newline at end of file
+class BlogAdmin(TitledAdmin):
+       pass
+
+
+class BlogEntryAdmin(TitledAdmin, AddTagAdmin):
+       filter_horizontal = ['tags']
+
+
+class BlogViewAdmin(EntityAdmin):
+       pass
+
+
+class NewsletterAdmin(TitledAdmin):
+       pass
+
+
+class NewsletterArticleAdmin(TitledAdmin, AddTagAdmin):
+       filter_horizontal = TitledAdmin.filter_horizontal + ('tags', 'authors')
+       list_display = ['title', 'date', 'author_names']
+       search_fields = ('title', 'authors__name',)
+       date_hierarchy = 'date'
+       
+       def author_names(self, obj):
+               return ', '.join([author.get_full_name() for author in obj.authors.all()])
+       author_names.short_description = "Authors"
+
+
+class NewsletterIssueAdmin(TitledAdmin):
+       filter_horizontal = TitledAdmin.filter_horizontal + ('articles',)
+
+
+class NewsletterViewAdmin(EntityAdmin):
+       pass
+
+
+admin.site.register(Blog, BlogAdmin)
+admin.site.register(BlogEntry, BlogEntryAdmin)
+admin.site.register(BlogView, BlogViewAdmin)
+admin.site.register(Newsletter, NewsletterAdmin)
+admin.site.register(NewsletterArticle, NewsletterArticleAdmin)
+admin.site.register(NewsletterIssue, NewsletterIssueAdmin)
+admin.site.register(NewsletterView, NewsletterViewAdmin)
\ No newline at end of file