summaryrefslogtreecommitdiff
path: root/archaeological_operations/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r--archaeological_operations/models.py33
1 files changed, 22 insertions, 11 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index d865c1ff9..c7a8c94ac 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -335,21 +335,32 @@ class Operation(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem):
return (max_val + 1) if max_val else 1
@classmethod
- def get_years(cls):
- max_year = datetime.date.today().year + 1
- return [res['year'] for res in list(
- cls.objects.exclude( year__isnull=True
- ).exclude(year__gt=max_year
- ).values('year'
- ).annotate(Count("id")).order_by())]
+ def get_periods(cls, slice='year', fltr={}):
+ q = cls.objects
+ if fltr:
+ q = q.filter(**fltr)
+ if slice == 'year':
+ max_year = datetime.date.today().year + 1
+ return [res['year'] for res in list(
+ q.exclude( year__isnull=True
+ ).exclude(year__gt=max_year
+ ).values('year'
+ ).annotate(Count("id")).order_by())]
+ return []
@classmethod
- def get_by_year(cls, year):
- return cls.objects.filter(year=year)
+ def get_by_year(cls, year, fltr={}):
+ q = cls.objects
+ if fltr:
+ q = q.filter(**fltr)
+ return q.filter(year=year)
@classmethod
- def get_total_number(cls):
- return cls.objects.count()
+ def get_total_number(cls, fltr={}):
+ q = cls.objects
+ if fltr:
+ q = q.filter(**fltr)
+ return q.count()
year_index_lbl = _(u"Operation code")
@property