From 9b8df05d258a28ea9d839cbb7511d41bc045f729 Mon Sep 17 00:00:00 2001 From: Cesar Augusto Date: Mon, 4 Feb 2019 13:38:21 -0200 Subject: [PATCH 1/3] Add method 'url_new_journal', 'url_previous_journal' in journal model --- opac_schema/v1/models.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/opac_schema/v1/models.py b/opac_schema/v1/models.py index 52dbbc9..247d0cd 100644 --- a/opac_schema/v1/models.py +++ b/opac_schema/v1/models.py @@ -446,6 +446,33 @@ def url(self): return URLegendarium(**leg_dict).url_journal + @property + def url_new_journal(self): + if self.next_title: + new_journal = self.__class__.objects( + title_slug=slugify(self.next_title) + ).first() + if new_journal: + url_new_journal = '/journal/%s' % new_journal.url_segment + else: + url_new_journal = "" + + return url_new_journal + + @property + def url_previous_journal(self): + if self.previous_journal_ref: + previous_journal = self.__class__.objects( + title_slug=slugify(self.previous_journal_ref) + ).first() + if previous_journal: + url_previous_journal = '/journal/%s' % previous_journal.url_segment + else: + url_previous_journal = "" + + return url_previous_journal + + signals.pre_save.connect(Journal.pre_save, sender=Journal) From 8b8077e6ff0d00f72f36ebd6d141502957608519 Mon Sep 17 00:00:00 2001 From: Cesar Augusto Date: Wed, 6 Feb 2019 16:39:32 -0200 Subject: [PATCH 2/3] =?UTF-8?q?Altera=C3=A7=C3=A3o=20do=20nome=20do=20meto?= =?UTF-8?q?do=20'url=5Fnew=5Fjournal'=20para=20'url=5Fnext=5Fjournal'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit para assim poder ter uma semantica melhor no nome do metodo e poder refletir melhor sua função, pois esse metodo se refere ao proximo periodico e nao ao periodico mais novo, pois a casos em que um periodico pode alterar de titulo varis vez na sua historia --- opac_schema/v1/models.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/opac_schema/v1/models.py b/opac_schema/v1/models.py index 247d0cd..4999f9a 100644 --- a/opac_schema/v1/models.py +++ b/opac_schema/v1/models.py @@ -447,17 +447,17 @@ def url(self): @property - def url_new_journal(self): + def url_next_journal(self): if self.next_title: - new_journal = self.__class__.objects( + next_journal = self.__class__.objects( title_slug=slugify(self.next_title) ).first() - if new_journal: - url_new_journal = '/journal/%s' % new_journal.url_segment + if next_journal: + url_next_journal = '/journal/%s' % next_journal.url_segment else: - url_new_journal = "" + url_next_journal = "" - return url_new_journal + return url_next_journal @property def url_previous_journal(self): From 969a1cd4bbef33e83ad3b5a72b3a4b6f1efbb8fc Mon Sep 17 00:00:00 2001 From: Cesar Augusto Date: Thu, 7 Feb 2019 09:31:00 -0200 Subject: [PATCH 3/3] =?UTF-8?q?Adiciona=20'URLegendarium'=20em=20gera?= =?UTF-8?q?=C3=A7=C3=A3o=20das=20url=5Fnext=5Fjournal=20e=20url=5Fprevious?= =?UTF-8?q?=5Fjournal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- opac_schema/v1/models.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/opac_schema/v1/models.py b/opac_schema/v1/models.py index 4999f9a..3a9eb51 100644 --- a/opac_schema/v1/models.py +++ b/opac_schema/v1/models.py @@ -448,27 +448,25 @@ def url(self): @property def url_next_journal(self): + url_next_journal = "" if self.next_title: next_journal = self.__class__.objects( title_slug=slugify(self.next_title) ).first() if next_journal: - url_next_journal = '/journal/%s' % next_journal.url_segment - else: - url_next_journal = "" + url_next_journal = URLegendarium(**{'acron': next_journal.acronym}).get_journal_seg() return url_next_journal @property def url_previous_journal(self): + url_previous_journal = "" if self.previous_journal_ref: previous_journal = self.__class__.objects( title_slug=slugify(self.previous_journal_ref) ).first() if previous_journal: - url_previous_journal = '/journal/%s' % previous_journal.url_segment - else: - url_previous_journal = "" + url_previous_journal = URLegendarium(**{'acron': previous_journal.acronym}).get_journal_seg() return url_previous_journal