+ index_page = models.ForeignKey(Page, related_name='newsletter_index_related')
+ article_page = models.ForeignKey(Page, related_name='newsletter_article_related')
+ article_archive_page = models.ForeignKey(Page, related_name='newsletter_article_archive_related', null=True, blank=True)
+ issue_page = models.ForeignKey(Page, related_name='newsletter_issue_related')
+ issue_archive_page = models.ForeignKey(Page, related_name='newsletter_issue_archive_related', null=True, blank=True)
+
+ article_permalink_style = models.CharField(max_length=1, choices=ARTICLE_PERMALINK_STYLE_CHOICES)
+ article_permalink_base = models.CharField(max_length=255, blank=False, default='articles')
+ issue_permalink_base = models.CharField(max_length=255, blank=False, default='issues')
+
+ feed_suffix = models.CharField(max_length=255, blank=False, default=FeedMultiViewMixin.feed_suffix)
+ feeds_enabled = models.BooleanField()
+ list_var = 'articles'
+
+ def __unicode__(self):
+ return self.newsletter.__unicode__()
+
+ def get_reverse_params(self, obj):
+ if isinstance(obj, NewsletterArticle):
+ if obj.newsletter == self.newsletter:
+ kwargs = {'slug': obj.slug}
+ if self.article_permalink_style in 'DMY':
+ kwargs.update({'year': str(obj.date.year).zfill(4)})
+ if self.article_permalink_style in 'DM':
+ kwargs.update({'month': str(obj.date.month).zfill(2)})
+ if self.article_permalink_style == 'D':
+ kwargs.update({'day': str(obj.date.day).zfill(2)})
+ return self.article_view, [], kwargs
+ elif isinstance(obj, NewsletterIssue):
+ if obj.newsletter == self.newsletter:
+ return 'issue', [], {'numbering': obj.numbering}
+ elif isinstance(obj, (date, datetime)):
+ kwargs = {
+ 'year': str(obj.year).zfill(4),
+ 'month': str(obj.month).zfill(2),
+ 'day': str(obj.day).zfill(2)
+ }
+ return 'articles_by_day', [], kwargs
+ raise ViewCanNotProvideSubpath