From c9a07e37189bec38f8951bd50ae5ec74318d60e4 Mon Sep 17 00:00:00 2001 From: lxf Date: Fri, 13 May 2022 17:32:45 -0400 Subject: lttr: made newsletter count automatically increment --- app/lttr/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/lttr') diff --git a/app/lttr/models.py b/app/lttr/models.py index a1a0c70..b4d1506 100644 --- a/app/lttr/models.py +++ b/app/lttr/models.py @@ -225,6 +225,7 @@ class NewsletterMailing(models.Model): class Meta: ordering = ('-pub_date', '-newsletter') + get_latest_by = "pub_date" def __str__(self): return self.title @@ -248,7 +249,10 @@ class NewsletterMailing(models.Model): self.body_markdown = self.post.body_markdown self.pub_date = self.post.pub_date self.featured_image = self.post.featured_image - self.issue = self.post.issue + if self.post.issue: + self.issue = self.post.issue + else: + self.issue = NewsletterMailing.objects.filter(newsletter=self.newsletter).latest().issue+1 if not created: md = render_images(self.body_markdown) self.body_html = markdown_to_html(md) -- cgit v1.2.3-70-g09d2