forked from CGM_Public/pretix_original
Minor refactoring
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -14,3 +14,4 @@ htmlcov/
|
|||||||
.ropeproject
|
.ropeproject
|
||||||
__pycache__/
|
__pycache__/
|
||||||
_static/
|
_static/
|
||||||
|
.idea
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ class EventRelatedCache:
|
|||||||
key = hashlib.sha256(key.encode("UTF-8")).hexdigest()
|
key = hashlib.sha256(key.encode("UTF-8")).hexdigest()
|
||||||
return key
|
return key
|
||||||
|
|
||||||
def _strip_prefix(self, key):
|
@staticmethod
|
||||||
|
def _strip_prefix(key):
|
||||||
return key.split(":", 3)[-1] if 'event:' in key else key
|
return key.split(":", 3)[-1] if 'event:' in key else key
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ from django.utils.translation.trans_real import (
|
|||||||
get_supported_language_variant,
|
get_supported_language_variant,
|
||||||
parse_accept_lang_header,
|
parse_accept_lang_header,
|
||||||
language_code_re,
|
language_code_re,
|
||||||
check_for_language,
|
check_for_language
|
||||||
_supported
|
|
||||||
)
|
)
|
||||||
from django.utils.translation import LANGUAGE_SESSION_KEY
|
from django.utils.translation import LANGUAGE_SESSION_KEY
|
||||||
from django.utils import translation, timezone
|
from django.utils import translation, timezone
|
||||||
@@ -17,6 +16,8 @@ from django.utils.cache import patch_vary_headers
|
|||||||
|
|
||||||
from tixlbase.models import Event
|
from tixlbase.models import Event
|
||||||
|
|
||||||
|
_supported = None
|
||||||
|
|
||||||
|
|
||||||
class LocaleMiddleware(BaseLocaleMiddleware):
|
class LocaleMiddleware(BaseLocaleMiddleware):
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ class User(AbstractBaseUser, PermissionsMixin):
|
|||||||
is_active = models.BooleanField(default=True,
|
is_active = models.BooleanField(default=True,
|
||||||
verbose_name=_('Is active'))
|
verbose_name=_('Is active'))
|
||||||
is_staff = models.BooleanField(default=False,
|
is_staff = models.BooleanField(default=False,
|
||||||
verbose_name=('Is site admin'))
|
verbose_name=_('Is site admin'))
|
||||||
date_joined = models.DateTimeField(auto_now_add=True,
|
date_joined = models.DateTimeField(auto_now_add=True,
|
||||||
verbose_name=_('Date joined'))
|
verbose_name=_('Date joined'))
|
||||||
locale = models.CharField(max_length=50,
|
locale = models.CharField(max_length=50,
|
||||||
@@ -97,7 +97,7 @@ class User(AbstractBaseUser, PermissionsMixin):
|
|||||||
verbose_name=_('Language'))
|
verbose_name=_('Language'))
|
||||||
timezone = models.CharField(max_length=100,
|
timezone = models.CharField(max_length=100,
|
||||||
default=settings.TIME_ZONE,
|
default=settings.TIME_ZONE,
|
||||||
verbose_name=('Timezone'))
|
verbose_name=_('Timezone'))
|
||||||
|
|
||||||
objects = UserManager()
|
objects = UserManager()
|
||||||
|
|
||||||
|
|||||||
@@ -30,17 +30,31 @@ class VariationDict(dict):
|
|||||||
|
|
||||||
def identify(self):
|
def identify(self):
|
||||||
"""
|
"""
|
||||||
Build an identifier for this dict. This can be any string used to
|
Build a simple and unique identifier for this dict. This can be any string
|
||||||
compare one VariationDict to others.
|
used to compare one VariationDict to others.
|
||||||
|
|
||||||
In the current implementation, it is a string containing a list of
|
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
|
the PropertyValue id's, sorted by the Property id's and is therefore
|
||||||
unique among one item.
|
unique among one item.
|
||||||
"""
|
"""
|
||||||
order_key = lambda i: i[0]
|
order_key = lambda i: i[0]
|
||||||
return ",".join([
|
return ",".join((
|
||||||
str(v[1].pk) for v in sorted(self.relevant_items(), key=order_key)
|
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):
|
def __eq__(self, other):
|
||||||
if type(other) is type(self):
|
if type(other) is type(self):
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
<a href="{% url "control:event.items.categories.up" organizer=request.event.organizer.slug event=request.event.slug category=c.pk %}" class="btn btn-default btn-sm {% if forloop.counter0 == 0 %}disabled{% endif %}"><i class="fa fa-arrow-up"></i></a>
|
<a href="{% url "control:event.items.categories.up" organizer=request.event.organizer.slug event=request.event.slug category=c.pk %}" class="btn btn-default btn-sm {% if forloop.counter0 == 0 %}disabled{% endif %}"><i class="fa fa-arrow-up"></i></a>
|
||||||
<a href="{% url "control:event.items.categories.down" organizer=request.event.organizer.slug event=request.event.slug category=c.pk %}" class="btn btn-default btn-sm {% if forloop.revcounter0 == 0 %}disabled{% endif %}"><i class="fa fa-arrow-down"></i></a>
|
<a href="{% url "control:event.items.categories.down" organizer=request.event.organizer.slug event=request.event.slug category=c.pk %}" class="btn btn-default btn-sm {% if forloop.revcounter0 == 0 %}disabled{% endif %}"><i class="fa fa-arrow-down"></i></a>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right"><a href="{% url "control:event.items.categories.delete" organizer=request.event.organizer.slug event=request.event.slug category=c.pk %}"" class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></a></td>
|
<td class="text-right"><a href="{% url "control:event.items.categories.delete" organizer=request.event.organizer.slug event=request.event.slug category=c.pk %}" class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
{% for p in properties %}
|
{% for p in properties %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><strong><a href="{% url "control:event.items.properties.edit" organizer=request.event.organizer.slug event=request.event.slug property=p.pk %}">{{ p.name }}</a></strong></td>
|
<td><strong><a href="{% url "control:event.items.properties.edit" organizer=request.event.organizer.slug event=request.event.slug property=p.pk %}">{{ p.name }}</a></strong></td>
|
||||||
<td class="text-right"><a href="{% url "control:event.items.properties.delete" organizer=request.event.organizer.slug event=request.event.slug property=p.pk %}"" class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></a></td>
|
<td class="text-right"><a href="{% url "control:event.items.properties.delete" organizer=request.event.organizer.slug event=request.event.slug property=p.pk %}" class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><strong><a href="{% url "control:event.items.questions.edit" organizer=request.event.organizer.slug event=request.event.slug question=q.pk %}">{{ q.question }}</a></strong></td>
|
<td><strong><a href="{% url "control:event.items.questions.edit" organizer=request.event.organizer.slug event=request.event.slug question=q.pk %}">{{ q.question }}</a></strong></td>
|
||||||
<td>{{ q.get_type_display }}</td>
|
<td>{{ q.get_type_display }}</td>
|
||||||
<td class="text-right"><a href="{% url "control:event.items.questions.delete" organizer=request.event.organizer.slug event=request.event.slug question=q.pk %}"" class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></a></td>
|
<td class="text-right"><a href="{% url "control:event.items.questions.delete" organizer=request.event.organizer.slug event=request.event.slug question=q.pk %}" class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ class TolerantFormsetModelForm(forms.ModelForm):
|
|||||||
# Always assume data has changed if validation fails.
|
# Always assume data has changed if validation fails.
|
||||||
self._changed_data.append(name)
|
self._changed_data.append(name)
|
||||||
continue
|
continue
|
||||||
|
# We're using a private API of Django here. This is not nice, but no problem as it seems
|
||||||
|
# like this will become a public API in Django 1.7.
|
||||||
if field._has_changed(initial_value, data_value):
|
if field._has_changed(initial_value, data_value):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -88,8 +88,7 @@ def availability_handler(sender, **kwargs):
|
|||||||
if 'variation' not in v or v['variation'] not in applied_to:
|
if 'variation' not in v or v['variation'] not in applied_to:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if (restriction.timeframe_from <= now()
|
if (restriction.timeframe_from <= now() <= restriction.timeframe_to):
|
||||||
and restriction.timeframe_to >= now()):
|
|
||||||
# Selling this item is currently possible
|
# Selling this item is currently possible
|
||||||
available = True
|
available = True
|
||||||
# If multiple time frames are currently active, make sure to
|
# If multiple time frames are currently active, make sure to
|
||||||
|
|||||||
Reference in New Issue
Block a user