forked from CGM_Public/pretix_original
Minor refactoring
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user