Author: aaugustin
Date: 2011-11-20 02:50:18 -0800 (Sun, 20 Nov 2011)
New Revision: 17122

Modified:
   django/trunk/django/contrib/auth/models.py
   django/trunk/django/contrib/auth/tests/remote_user.py
Log:
Upgraded django.contrib.auth to be compatible with time zone support.



Modified: django/trunk/django/contrib/auth/models.py
===================================================================
--- django/trunk/django/contrib/auth/models.py  2011-11-20 10:33:44 UTC (rev 
17121)
+++ django/trunk/django/contrib/auth/models.py  2011-11-20 10:50:18 UTC (rev 
17122)
@@ -1,4 +1,3 @@
-import datetime
 import urllib
 
 from django.core.exceptions import ImproperlyConfigured
@@ -7,6 +6,7 @@
 from django.db.models.manager import EmptyManager
 from django.utils.encoding import smart_str
 from django.utils.translation import ugettext_lazy as _
+from django.utils import timezone
 
 from django.contrib import auth
 from django.contrib.auth.signals import user_logged_in
@@ -21,7 +21,7 @@
     A signal receiver which updates the last_login date for
     the user logging in.
     """
-    user.last_login = datetime.datetime.now()
+    user.last_login = timezone.now()
     user.save()
 user_logged_in.connect(update_last_login)
 
@@ -91,7 +91,7 @@
         """
         Creates and saves a User with the given username, email and password.
         """
-        now = datetime.datetime.now()
+        now = timezone.now()
 
         # Normalize the address by lowercasing the domain part of the email
         # address.
@@ -181,8 +181,8 @@
     is_staff = models.BooleanField(_('staff status'), default=False, 
help_text=_("Designates whether the user can log into this admin site."))
     is_active = models.BooleanField(_('active'), default=True, 
help_text=_("Designates whether this user should be treated as active. Unselect 
this instead of deleting accounts."))
     is_superuser = models.BooleanField(_('superuser status'), default=False, 
help_text=_("Designates that this user has all permissions without explicitly 
assigning them."))
-    last_login = models.DateTimeField(_('last login'), 
default=datetime.datetime.now)
-    date_joined = models.DateTimeField(_('date joined'), 
default=datetime.datetime.now)
+    last_login = models.DateTimeField(_('last login'), default=timezone.now)
+    date_joined = models.DateTimeField(_('date joined'), default=timezone.now)
     groups = models.ManyToManyField(Group, verbose_name=_('groups'), 
blank=True,
         help_text=_("In addition to the permissions manually assigned, this 
user will also get all permissions granted to each group he/she is in."))
     user_permissions = models.ManyToManyField(Permission, verbose_name=_('user 
permissions'), blank=True)

Modified: django/trunk/django/contrib/auth/tests/remote_user.py
===================================================================
--- django/trunk/django/contrib/auth/tests/remote_user.py       2011-11-20 
10:33:44 UTC (rev 17121)
+++ django/trunk/django/contrib/auth/tests/remote_user.py       2011-11-20 
10:50:18 UTC (rev 17122)
@@ -4,6 +4,7 @@
 from django.contrib.auth.backends import RemoteUserBackend
 from django.contrib.auth.models import User
 from django.test import TestCase
+from django.utils import timezone
 
 
 class RemoteUserTest(TestCase):
@@ -80,6 +81,8 @@
         user = User.objects.create(username='knownuser')
         # Set last_login to something so we can determine if it changes.
         default_login = datetime(2000, 1, 1)
+        if settings.USE_TZ:
+            default_login = default_login.replace(tzinfo=timezone.utc)
         user.last_login = default_login
         user.save()
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to