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.utils.translation import ugettext_lazy as _
|
||||
from pytz import common_timezones
|
||||
|
||||
from pretix.base.models import User
|
||||
|
||||
@@ -31,17 +32,19 @@ class UserSettingsForm(forms.ModelForm):
|
||||
required=False,
|
||||
label=_("Repeat new password"),
|
||||
widget=forms.PasswordInput())
|
||||
# timezone = forms.ChoiceField(
|
||||
# choices=((a, a) for a in common_timezones),
|
||||
# label=_("Default timezone"),
|
||||
# )
|
||||
timezone = forms.ChoiceField(
|
||||
choices=((a, a) for a in common_timezones),
|
||||
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:
|
||||
model = User
|
||||
fields = [
|
||||
'fullname',
|
||||
'locale',
|
||||
# 'timezone',
|
||||
'timezone',
|
||||
'email'
|
||||
]
|
||||
|
||||
|
||||
@@ -47,10 +47,10 @@ class LocaleMiddleware(MiddlewareMixin):
|
||||
request.LANGUAGE_CODE = translation.get_language()
|
||||
|
||||
tzname = None
|
||||
if request.user.is_authenticated:
|
||||
tzname = request.user.timezone
|
||||
if hasattr(request, 'event'):
|
||||
tzname = request.event.settings.timezone
|
||||
elif request.user.is_authenticated:
|
||||
tzname = request.user.timezone
|
||||
if tzname:
|
||||
try:
|
||||
timezone.activate(pytz.timezone(tzname))
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<legend>{% trans "General settings" %}</legend>
|
||||
{% bootstrap_field form.fullname layout='horizontal' %}
|
||||
{% bootstrap_field form.locale layout='horizontal' %}
|
||||
{% bootstrap_field form.timezone layout='horizontal' %}
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>{% trans "Login settings" %}</legend>
|
||||
|
||||
Reference in New Issue
Block a user