1 from datetime import date
2 from functools import wraps
4 from django.db.models import Count
9 View decorator, which puts tab info on a request.
13 def wrapped(request, *args, **kwargs):
14 request.catalogue_active_tab = tab
15 return f(request, *args, **kwargs)
20 def cached_in_field(field_name):
24 def wrapped(self, *args, **kwargs):
25 value = getattr(self, field_name)
27 value = f(self, *args, **kwargs)
28 type(self)._default_manager.filter(pk=self.pk).update(**{field_name: value})
34 def parse_isodate(isodate):
36 return date(*[int(p) for p in isodate.split('-')])
37 except (AttributeError, TypeError, ValueError):
38 raise ValueError("Not a date in ISO format.")