From 9ad2525a47fa37193c56404fbc693d73c3fa166e Mon Sep 17 00:00:00 2001 From: Keegan Landrigan Date: Thu, 20 Aug 2020 00:24:51 +0000 Subject: [PATCH 1/2] get_absolute_url changed for guide articles --- dispatch/modules/content/models.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dispatch/modules/content/models.py b/dispatch/modules/content/models.py index 11b26edbf..f082181ac 100644 --- a/dispatch/modules/content/models.py +++ b/dispatch/modules/content/models.py @@ -398,7 +398,16 @@ def save_topic(self, topic_id): pass def get_absolute_url(self): - """ Returns article URL. """ + """ Returns article URL. Uses alternate logic when section slug is 'guide'""" + if self.section.slug == 'guide' and self.subsection: + # Subsection is "supposed" to be optional in most circumstances. But it's needed for guide URLs, so we need to check self.subsection. + # Worst case scenario should the viewer will see a guide article in the wrong template + if self.published_at is not None: + year = self.published_at.strftime("%Y") + else: + # You might enter this block when you are writing a new guide article and there is no published_at yet. + year = datetime.datetime.now().strftime("%Y") + return "%s%s/%s/%s/%s/" % (settings.BASE_URL, self.section.slug, year, self.subsection.slug, self.slug) return "%s%s/%s/" % (settings.BASE_URL, self.section.slug, self.slug) def get_subsection(self): From bd52caa090ee0354ebf386f1d8e6b5e410b991fc Mon Sep 17 00:00:00 2001 From: Keegan Landrigan Date: Thu, 20 Aug 2020 19:58:47 +0000 Subject: [PATCH 2/2] bump version -->1.3.6 for pypi --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e49a15b72..80a002ac2 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup(name='dispatch', description='A publishing platform for modern newspapers', - version='1.3.5', + version='1.3.6', url='https://github.com/ubyssey/dispatch', author='Peter Siemens', author_email='peterjsiemens@gmail.com',