diff --git a/.gitignore b/.gitignore index 984568a3b3..fc6eb78d0f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ htmlcov/ .ropeproject __pycache__/ _static/ +.idea diff --git a/src/tixlbase/cache.py b/src/tixlbase/cache.py index 4efd0bf72c..7a30a9525d 100644 --- a/src/tixlbase/cache.py +++ b/src/tixlbase/cache.py @@ -38,7 +38,8 @@ class EventRelatedCache: key = hashlib.sha256(key.encode("UTF-8")).hexdigest() return key - def _strip_prefix(self, key): + @staticmethod + def _strip_prefix(key): return key.split(":", 3)[-1] if 'event:' in key else key def clear(self): diff --git a/src/tixlbase/middleware.py b/src/tixlbase/middleware.py index 7967e16649..b0f0cefe79 100644 --- a/src/tixlbase/middleware.py +++ b/src/tixlbase/middleware.py @@ -7,8 +7,7 @@ from django.utils.translation.trans_real import ( get_supported_language_variant, parse_accept_lang_header, language_code_re, - check_for_language, - _supported + check_for_language ) from django.utils.translation import LANGUAGE_SESSION_KEY from django.utils import translation, timezone @@ -17,6 +16,8 @@ from django.utils.cache import patch_vary_headers from tixlbase.models import Event +_supported = None + class LocaleMiddleware(BaseLocaleMiddleware): diff --git a/src/tixlbase/models.py b/src/tixlbase/models.py index 8bba4a65ed..71ce5e64c8 100644 --- a/src/tixlbase/models.py +++ b/src/tixlbase/models.py @@ -88,7 +88,7 @@ class User(AbstractBaseUser, PermissionsMixin): is_active = models.BooleanField(default=True, verbose_name=_('Is active')) is_staff = models.BooleanField(default=False, - verbose_name=('Is site admin')) + verbose_name=_('Is site admin')) date_joined = models.DateTimeField(auto_now_add=True, verbose_name=_('Date joined')) locale = models.CharField(max_length=50, @@ -97,7 +97,7 @@ class User(AbstractBaseUser, PermissionsMixin): verbose_name=_('Language')) timezone = models.CharField(max_length=100, default=settings.TIME_ZONE, - verbose_name=('Timezone')) + verbose_name=_('Timezone')) objects = UserManager() diff --git a/src/tixlbase/types.py b/src/tixlbase/types.py index 4f222f5b55..62cc361ff6 100644 --- a/src/tixlbase/types.py +++ b/src/tixlbase/types.py @@ -30,17 +30,31 @@ class VariationDict(dict): def identify(self): """ - Build an identifier for this dict. This can be any string used to - compare one VariationDict to others. + Build a simple and unique identifier for this dict. This can be any string + used to compare one VariationDict to others. In the current implementation, it is a string containing a list of the PropertyValue id's, sorted by the Property id's and is therefore unique among one item. """ order_key = lambda i: i[0] - return ",".join([ + return ",".join(( str(v[1].pk) for v in sorted(self.relevant_items(), key=order_key) - ]) + )) + + def key(self): + """ + Build an identifier for this dict which exactly specifies the combination + for this variation without any doubt. This can be used to "talk" about a + variation in network communication. + + In the current implementation, it is a string containing a list of + the propertyid:valueid tuples without any specific order and is therefore + not useful to compare two VariationDicts for equality. + """ + return ",".join(( + str(v[0]) + ":" + str(v[1].pk) for v in self.relevant_items() + )) def __eq__(self, other): if type(other) is type(self): diff --git a/src/tixlcontrol/templates/tixlcontrol/items/categories.html b/src/tixlcontrol/templates/tixlcontrol/items/categories.html index f5168b54d0..99b7feb420 100644 --- a/src/tixlcontrol/templates/tixlcontrol/items/categories.html +++ b/src/tixlcontrol/templates/tixlcontrol/items/categories.html @@ -35,7 +35,7 @@ -