forked from CGM_Public/pretix_original
Re-add option to set user timezone
This commit is contained in:
@@ -5,6 +5,7 @@ from django.contrib.auth.password_validation import (
|
|||||||
)
|
)
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
from pytz import common_timezones
|
||||||
|
|
||||||
from pretix.base.models import User
|
from pretix.base.models import User
|
||||||
|
|
||||||
@@ -31,17 +32,19 @@ class UserSettingsForm(forms.ModelForm):
|
|||||||
required=False,
|
required=False,
|
||||||
label=_("Repeat new password"),
|
label=_("Repeat new password"),
|
||||||
widget=forms.PasswordInput())
|
widget=forms.PasswordInput())
|
||||||
# timezone = forms.ChoiceField(
|
timezone = forms.ChoiceField(
|
||||||
# choices=((a, a) for a in common_timezones),
|
choices=((a, a) for a in common_timezones),
|
||||||
# label=_("Default timezone"),
|
label=_("Default timezone"),
|
||||||
# )
|
help_text=_('Only used for views that are not bound to an event. For all '
|
||||||
|
'event views, the event timezone is used instead.')
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
fields = [
|
fields = [
|
||||||
'fullname',
|
'fullname',
|
||||||
'locale',
|
'locale',
|
||||||
# 'timezone',
|
'timezone',
|
||||||
'email'
|
'email'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -47,10 +47,10 @@ class LocaleMiddleware(MiddlewareMixin):
|
|||||||
request.LANGUAGE_CODE = translation.get_language()
|
request.LANGUAGE_CODE = translation.get_language()
|
||||||
|
|
||||||
tzname = None
|
tzname = None
|
||||||
if request.user.is_authenticated:
|
|
||||||
tzname = request.user.timezone
|
|
||||||
if hasattr(request, 'event'):
|
if hasattr(request, 'event'):
|
||||||
tzname = request.event.settings.timezone
|
tzname = request.event.settings.timezone
|
||||||
|
elif request.user.is_authenticated:
|
||||||
|
tzname = request.user.timezone
|
||||||
if tzname:
|
if tzname:
|
||||||
try:
|
try:
|
||||||
timezone.activate(pytz.timezone(tzname))
|
timezone.activate(pytz.timezone(tzname))
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
<legend>{% trans "General settings" %}</legend>
|
<legend>{% trans "General settings" %}</legend>
|
||||||
{% bootstrap_field form.fullname layout='horizontal' %}
|
{% bootstrap_field form.fullname layout='horizontal' %}
|
||||||
{% bootstrap_field form.locale layout='horizontal' %}
|
{% bootstrap_field form.locale layout='horizontal' %}
|
||||||
|
{% bootstrap_field form.timezone layout='horizontal' %}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{% trans "Login settings" %}</legend>
|
<legend>{% trans "Login settings" %}</legend>
|
||||||
|
|||||||
Reference in New Issue
Block a user