Add support for timezone/language settings #11

Merged
merged 5 commits into from Apr 13, 2012

2 participants

@paltman
Pinax Project member

No description provided.

@brosner brosner commented on an outdated diff Apr 11, 2012
account/fields.py
@@ -0,0 +1,21 @@
+from django.conf import settings
+from django.db import models
+
+import pytz
+
+
+TIMEZONE_CHOICES = tuple(zip(pytz.all_timezones, pytz.all_timezones))
@brosner
Pinax Project member
brosner added a note Apr 11, 2012

This constant seems useless to me. Either we should inline this or make it configurable via settings.

@brosner
Pinax Project member
brosner added a note Apr 11, 2012

Oh, I see it being used elsewhere. Let's make it configurable via settings in conf.py.

@brosner
Pinax Project member
brosner added a note Apr 11, 2012

Also, I don't know what I was smoking to allow this to be a tuple. Uselist instead as it that is the correct data structure for choices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@brosner brosner commented on an outdated diff Apr 11, 2012
account/models.py
@@ -227,3 +270,9 @@ def send(self):
self.sent = timezone.now()
self.save()
signals.email_confirmation_sent.send(sender=self.__class__, confirmation=self)
+
+
+@receiver(post_save, sender=User)
+def create_account(sender, **kwargs):
+ if kwargs["created"]:
+ Account.objects.get_or_create(user=kwargs["instance"])
@brosner
Pinax Project member
brosner added a note Apr 11, 2012

We talked about not using get_or_create because we check for created in kwargs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@brosner brosner commented on an outdated diff Apr 11, 2012
account/fields.py
@@ -0,0 +1,16 @@
+from django.conf import settings
@brosner
Pinax Project member
brosner added a note Apr 11, 2012

This is incorrect. You need: from account.conf import settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@brosner brosner and 1 other commented on an outdated diff Apr 11, 2012
account/fields.py
@@ -0,0 +1,16 @@
+from django.conf import settings
+from django.db import models
+
+
+class TimeZoneField(models.CharField):
+
+ __metaclass__ = models.SubfieldBase
+
+ def __init__(self, *args, **kwargs):
+ defaults = {
+ "max_length": 100,
+ "default": settings.TIME_ZONE,
+ "choices": settings.TIMEZONE_CHOICES
@brosner
Pinax Project member
brosner added a note Apr 11, 2012

This is also incorrect. It should be: settings.ACCOUNT_TIMEZONE_CHOICES

@paltman
Pinax Project member
paltman added a note Apr 11, 2012

should it default to the pytz list of values?

@brosner
Pinax Project member
brosner added a note Apr 11, 2012

The code you have in conf.py is correct. This line is incorrect because appconf prefixes what you add in the conf with ACCOUNT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@brosner brosner merged commit 2a8c9f8 into master Apr 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment