+ form = DelayedDateForm
+ filter_horizontal = ('tags', 'authors')
+ list_filter = ('newsletter',)
+ date_hierarchy = 'date'
+ search_fields = ('title', 'authors__name',)
+ list_display = ['title', 'date', 'author_names']
+ fieldsets = (
+ (None, {
+ 'fields': ('title', 'authors', 'newsletter')
+ }),
+ ('Content', {
+ 'fields': ('full_text', 'lede', 'tags')
+ }),
+ ('Advanced', {
+ 'fields': ('slug', 'date'),
+ '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"