Remove timezone
This commit is contained in:
parent
d7b1910839
commit
6162bd984f
4 changed files with 18 additions and 20 deletions
|
@ -1,13 +0,0 @@
|
||||||
import pytz
|
|
||||||
|
|
||||||
from django.utils import timezone
|
|
||||||
|
|
||||||
|
|
||||||
class TimezoneMiddleware(object):
|
|
||||||
def process_request(self, request):
|
|
||||||
if not request.user.is_anonymous():
|
|
||||||
tzname = request.user.timezone
|
|
||||||
if tzname:
|
|
||||||
timezone.activate(pytz.timezone(tzname))
|
|
||||||
else:
|
|
||||||
timezone.deactivate()
|
|
18
ccdb/users/migrations/0003_remove_user_timezone.py
Normal file
18
ccdb/users/migrations/0003_remove_user_timezone.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('users', '0002_timezone'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='user',
|
||||||
|
name='timezone',
|
||||||
|
),
|
||||||
|
]
|
|
@ -3,15 +3,9 @@ from django.core.urlresolvers import reverse
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
import pytz
|
|
||||||
|
|
||||||
|
|
||||||
class User(AbstractUser):
|
class User(AbstractUser):
|
||||||
name = models.CharField(_("Name of User"), blank=True, max_length=255)
|
name = models.CharField(_("Name of User"), blank=True, max_length=255)
|
||||||
timezone = models.CharField(_("Current Timezone"), max_length=255,
|
|
||||||
default="UTC",
|
|
||||||
choices=[(x, x) for x in pytz.common_timezones],
|
|
||||||
blank=False)
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.username
|
return self.username
|
||||||
|
|
|
@ -58,7 +58,6 @@ MIDDLEWARE_CLASSES = (
|
||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
'ccdb.users.middleware.TimezoneMiddleware',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# DEBUG
|
# DEBUG
|
||||||
|
|
Loading…
Add table
Reference in a new issue