diff --git a/journals/models.py b/journals/models.py index 9646853c69880f42447ac2dfa0bb927b0abc451e..d858d6bcc51394a7f299831ae2f5011494c52e87 100644 --- a/journals/models.py +++ b/journals/models.py @@ -169,6 +169,10 @@ class IssueManager(models.Manager): until_date__gte=timezone.now(), **kwargs).order_by('-until_date').first() + def get_last_filled_issue(self, *args, **kwargs): + return self.published(publication__isnull=False, + **kwargs).order_by('-until_date').first() + class Issue(models.Model): in_volume = models.ForeignKey(Volume, on_delete=models.CASCADE) @@ -199,6 +203,10 @@ class Issue(models.Model): return (' (' + self.start_date.strftime('%B') + '-' + self.until_date.strftime('%B') + ' ' + self.until_date.strftime('%Y') + ')') + def is_current(self): + return self.start_date <= timezone.now().date() and\ + self.until_date >= timezone.now().date() + def period(self): text = 'up to {{ until_month }} {{ year }}' template = Template(text)