Dot-Notation for Users.fp_token_expire
authorElrond <elrond+mediagoblin.org@samba-tng.org>
Mon, 14 Nov 2011 18:24:15 +0000 (19:24 +0100)
committerElrond <elrond+mediagoblin.org@samba-tng.org>
Mon, 5 Dec 2011 20:08:58 +0000 (21:08 +0100)
mediagoblin/auth/views.py
mediagoblin/tests/test_auth.py

index 633ceef4b61045cc3e2fdf0270e691e372414a21..919aa3cd62d993907c0ccc8ee0cb8c4f35b2a493 100644 (file)
@@ -251,7 +251,7 @@ def forgot_password(request):
         if user:
             if user.email_verified and user.status == 'active':
                 user.fp_verification_key = unicode(uuid.uuid4())
-                user[u'fp_token_expire'] = datetime.datetime.now() + \
+                user.fp_token_expire = datetime.datetime.now() + \
                                           datetime.timedelta(days=10)
                 user.save()
 
@@ -303,7 +303,7 @@ def verify_forgot_password(request):
     # check if we have a real user and correct token
     if ((user and user.fp_verification_key and
          user.fp_verification_key == unicode(formdata_token) and
-         datetime.datetime.now() < user['fp_token_expire']
+         datetime.datetime.now() < user.fp_token_expire
          and user.email_verified and user.status == 'active')):
 
         cp_form = auth_forms.ChangePassForm(formdata_vars)
@@ -312,7 +312,7 @@ def verify_forgot_password(request):
             user.pw_hash = auth_lib.bcrypt_gen_password_hash(
                 request.POST['password'])
             user.fp_verification_key = None
-            user[u'fp_token_expire'] = None
+            user.fp_token_expire = None
             user.save()
 
             return redirect(request, 'mediagoblin.auth.fp_changed_success')
index 2dcb5c14ca2df0d17a6adfd507393c4a8568ea1e..d3b8caf1c393e674cb5c55bca287a76efef8822f 100644 (file)
@@ -274,7 +274,7 @@ def test_register_views(test_app):
 
     ### The forgotten password token should be set to expire in ~ 10 days
     # A few ticks have expired so there are only 9 full days left...
-    assert (new_user['fp_token_expire'] - datetime.datetime.now()).days == 9
+    assert (new_user.fp_token_expire - datetime.datetime.now()).days == 9
 
     ## Try using a bs password-changing verification key, shouldn't work
     template.clear_test_template_context()
@@ -285,12 +285,12 @@ def test_register_views(test_app):
 
     ## Try using an expired token to change password, shouldn't work
     template.clear_test_template_context()
-    real_token_expiration = new_user['fp_token_expire']
-    new_user['fp_token_expire'] = datetime.datetime.now()
+    real_token_expiration = new_user.fp_token_expire
+    new_user.fp_token_expire = datetime.datetime.now()
     new_user.save()
     response = test_app.get("%s?%s" % (path, get_params), status=404)
     assert_equal(response.status, '404 Not Found')
-    new_user['fp_token_expire'] = real_token_expiration
+    new_user.fp_token_expire = real_token_expiration
     new_user.save()
 
     ## Verify step 1 of password-change works -- can see form to change password