Fix PublicationYear.publis
returning special publications
This commit is contained in:
parent
673ce754f6
commit
23466d3717
2 changed files with 7 additions and 1 deletions
|
@ -5,7 +5,7 @@ from . import models
|
|||
|
||||
def sidebar_years(req):
|
||||
avail_years = models.PublicationYear.objects.all()
|
||||
publi_years = [year for year in avail_years if len(year.publis()) > 0]
|
||||
publi_years = [year for year in avail_years if year.publis().count() > 0]
|
||||
|
||||
num_special_publications = models.Publication.objects\
|
||||
.filter(is_special=True).count()
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from django.db import models
|
||||
from django.db.models import Q
|
||||
from django.db.models import DateField, \
|
||||
CharField, \
|
||||
BooleanField, \
|
||||
|
@ -84,6 +85,10 @@ class Publication(models.Model):
|
|||
return self.num
|
||||
return 'BOcal n°{}'.format(self.num)
|
||||
|
||||
@staticmethod
|
||||
def latest():
|
||||
return Publication.objects.order_by('-date')[0]
|
||||
|
||||
class Meta:
|
||||
ordering = ['date']
|
||||
|
||||
|
@ -111,6 +116,7 @@ class PublicationYear(models.Model):
|
|||
def publis(self):
|
||||
''' List of publications from this year '''
|
||||
return Publication.objects.filter(
|
||||
Q(is_special=False) | Q(in_year_view_anyway=True),
|
||||
date__gte=self.beg(),
|
||||
date__lt=self.end())
|
||||
|
||||
|
|
Loading…
Reference in a new issue