X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/17d46134395cc0584ed6ba54b69e47490dc5b6a9..785b59352880027f54ea0e81335d179eccee75f1:/contrib/penfield/admin.py diff --git a/contrib/penfield/admin.py b/contrib/penfield/admin.py index d8fcd90..c70cf46 100644 --- a/contrib/penfield/admin.py +++ b/contrib/penfield/admin.py @@ -1,5 +1,7 @@ -from django.contrib import admin from django import forms +from django.contrib import admin +from django.core.urlresolvers import reverse +from django.http import HttpResponseRedirect, QueryDict from philo.admin import EntityAdmin, AddTagAdmin, COLLAPSE_CLASSES from philo.contrib.penfield.models import BlogEntry, Blog, BlogView, Newsletter, NewsletterArticle, NewsletterIssue, NewsletterView @@ -41,6 +43,7 @@ class BlogEntryAdmin(TitledAdmin, AddTagAdmin): 'classes': COLLAPSE_CLASSES }) ) + related_lookup_fields = {'fk': raw_id_fields} class BlogViewAdmin(EntityAdmin): @@ -54,16 +57,17 @@ class BlogViewAdmin(EntityAdmin): ('Archive Pages', { 'fields': ('entry_archive_page', 'tag_archive_page') }), - ('Permalinks', { - 'fields': ('entry_permalink_style', 'entry_permalink_base', 'tag_permalink_base'), + ('General Settings', { + 'fields': ('entry_permalink_style', 'entry_permalink_base', 'tag_permalink_base', 'entries_per_page'), 'classes': COLLAPSE_CLASSES }), - ('Feeds', { - 'fields': ('feed_suffix', 'feeds_enabled'), + ('Feed Settings', { + 'fields': ( 'feeds_enabled', 'feed_suffix', 'feed_type', 'feed_length', 'item_title_template', 'item_description_template',), 'classes': COLLAPSE_CLASSES }) ) - raw_id_fields = ('index_page', 'entry_page', 'tag_page', 'entry_archive_page', 'tag_archive_page',) + raw_id_fields = ('index_page', 'entry_page', 'tag_page', 'entry_archive_page', 'tag_archive_page', 'item_title_template', 'item_description_template',) + related_lookup_fields = {'fk': raw_id_fields} class NewsletterAdmin(TitledAdmin): @@ -89,10 +93,18 @@ class NewsletterArticleAdmin(TitledAdmin, AddTagAdmin): 'classes': COLLAPSE_CLASSES }) ) + actions = ['make_issue'] def author_names(self, obj): return ', '.join([author.get_full_name() for author in obj.authors.all()]) author_names.short_description = "Authors" + + def make_issue(self, request, queryset): + opts = NewsletterIssue._meta + info = opts.app_label, opts.module_name + url = reverse("admin:%s_%s_add" % info) + return HttpResponseRedirect("%s?articles=%s" % (url, ",".join([str(a.pk) for a in queryset]))) + make_issue.short_description = u"Create issue from selected %(verbose_name_plural)s" class NewsletterIssueAdmin(TitledAdmin): @@ -115,11 +127,12 @@ class NewsletterViewAdmin(EntityAdmin): 'classes': COLLAPSE_CLASSES }), ('Feeds', { - 'fields': ('feed_suffix', 'feeds_enabled'), + 'fields': ( 'feeds_enabled', 'feed_suffix', 'feed_type', 'feed_length', 'item_title_template', 'item_description_template',), 'classes': COLLAPSE_CLASSES }) ) - raw_id_fields = ('index_page', 'article_page', 'issue_page', 'article_archive_page', 'issue_archive_page',) + raw_id_fields = ('index_page', 'article_page', 'issue_page', 'article_archive_page', 'issue_archive_page', 'item_title_template', 'item_description_template',) + related_lookup_fields = {'fk': raw_id_fields} admin.site.register(Blog, BlogAdmin)