From 7a3d00ec217cc3fd44788b9d8c63ab9f7b1d05a7 Mon Sep 17 00:00:00 2001 From: Elrond Date: Mon, 14 Nov 2011 19:01:26 +0100 Subject: [PATCH] Dot-Notation for Users.status --- mediagoblin/auth/views.py | 6 +++--- mediagoblin/gmg_commands/users.py | 2 +- mediagoblin/templates/mediagoblin/base.html | 2 +- mediagoblin/tests/test_auth.py | 6 +++--- mediagoblin/user_pages/views.py | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mediagoblin/auth/views.py b/mediagoblin/auth/views.py index 2d29d0a5..caf9835a 100644 --- a/mediagoblin/auth/views.py +++ b/mediagoblin/auth/views.py @@ -167,7 +167,7 @@ def verify_email(request): {'_id': ObjectId(unicode(request.GET['userid']))}) if user and user['verification_key'] == unicode(request.GET['token']): - user[u'status'] = u'active' + user.status = u'active' user.email_verified = True user[u'verification_key'] = None @@ -249,7 +249,7 @@ def forgot_password(request): {'email': request.POST['username']}) if user: - if user.email_verified and user['status'] == 'active': + if user.email_verified and user.status == 'active': user[u'fp_verification_key'] = unicode(uuid.uuid4()) user[u'fp_token_expire'] = datetime.datetime.now() + \ datetime.timedelta(days=10) @@ -304,7 +304,7 @@ def verify_forgot_password(request): if ((user and user['fp_verification_key'] and user['fp_verification_key'] == unicode(formdata_token) and datetime.datetime.now() < user['fp_token_expire'] - and user.email_verified and user['status'] == 'active')): + and user.email_verified and user.status == 'active')): cp_form = auth_forms.ChangePassForm(formdata_vars) diff --git a/mediagoblin/gmg_commands/users.py b/mediagoblin/gmg_commands/users.py index 88895661..7b23ba34 100644 --- a/mediagoblin/gmg_commands/users.py +++ b/mediagoblin/gmg_commands/users.py @@ -53,7 +53,7 @@ def adduser(args): entry.username = unicode(args.username.lower()) entry.email = unicode(args.email) entry.pw_hash = auth_lib.bcrypt_gen_password_hash(args.password) - entry['status'] = u'active' + entry.status = u'active' entry.email_verified = True entry.save(validate=True) diff --git a/mediagoblin/templates/mediagoblin/base.html b/mediagoblin/templates/mediagoblin/base.html index c06addd0..16569f03 100644 --- a/mediagoblin/templates/mediagoblin/base.html +++ b/mediagoblin/templates/mediagoblin/base.html @@ -48,7 +48,7 @@ >{% trans %}MediaGoblin logo{% endtrans %} {% endblock %} - {% if request.user and request.user['status'] == 'active' %} + {% if request.user and request.user.status == 'active' %} {% trans %}Submit media{% endtrans %} diff --git a/mediagoblin/tests/test_auth.py b/mediagoblin/tests/test_auth.py index ad9a5bca..bd79a407 100644 --- a/mediagoblin/tests/test_auth.py +++ b/mediagoblin/tests/test_auth.py @@ -162,7 +162,7 @@ def test_register_views(test_app): new_user = mg_globals.database.User.find_one( {'username': 'happygirl'}) assert new_user - assert new_user['status'] == u'needs_email_verification' + assert new_user.status == u'needs_email_verification' assert new_user.email_verified == False ## Make sure user is logged in @@ -202,7 +202,7 @@ def test_register_views(test_app): new_user = mg_globals.database.User.find_one( {'username': 'happygirl'}) assert new_user - assert new_user['status'] == u'needs_email_verification' + assert new_user.status == u'needs_email_verification' assert new_user.email_verified == False ## Verify the email activation works @@ -216,7 +216,7 @@ def test_register_views(test_app): new_user = mg_globals.database.User.find_one( {'username': 'happygirl'}) assert new_user - assert new_user['status'] == u'active' + assert new_user.status == u'active' assert new_user.email_verified == True # Uniqueness checks diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py index ad33479b..4b311822 100644 --- a/mediagoblin/user_pages/views.py +++ b/mediagoblin/user_pages/views.py @@ -40,7 +40,7 @@ def user_home(request, page): 'username': request.matchdict['user']}) if not user: return render_404(request) - elif user['status'] != u'active': + elif user.status != u'active': return render_to_response( request, 'mediagoblin/user_pages/user.html', @@ -254,7 +254,7 @@ def processing_panel(request): # Make sure the user exists and is active if not user: return render_404(request) - elif user['status'] != u'active': + elif user.status != u'active': return render_to_response( request, 'mediagoblin/user_pages/user.html', -- 2.25.1