X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/b0af42626632f8750ac9e88338be7e196bd4f91d..5913c54d19b8f6775633176032161d49f9b2f1aa:/apps/catalogue/helpers.py?ds=sidebyside diff --git a/apps/catalogue/helpers.py b/apps/catalogue/helpers.py deleted file mode 100644 index df64ade1..00000000 --- a/apps/catalogue/helpers.py +++ /dev/null @@ -1,38 +0,0 @@ -from datetime import date -from functools import wraps - -from django.db.models import Count - - -def active_tab(tab): - """ - View decorator, which puts tab info on a request. - """ - def wrapper(f): - @wraps(f) - def wrapped(request, *args, **kwargs): - request.catalogue_active_tab = tab - return f(request, *args, **kwargs) - return wrapped - return wrapper - - -def cached_in_field(field_name): - def decorator(f): - @property - @wraps(f) - def wrapped(self, *args, **kwargs): - value = getattr(self, field_name) - if value is None: - value = f(self, *args, **kwargs) - type(self)._default_manager.filter(pk=self.pk).update(**{field_name: value}) - return value - return wrapped - return decorator - - -def parse_isodate(isodate): - try: - return date(*[int(p) for p in isodate.split('-')]) - except (AttributeError, TypeError, ValueError): - raise ValueError("Not a date in ISO format.")