From cfe46f3e68b62bba0cfb943dc45e9b88c3f7c25e Mon Sep 17 00:00:00 2001 From: Caleb Forbes Davis V Date: Mon, 4 Jul 2011 19:42:45 -0500 Subject: [PATCH 1/2] uses the messaging system to notify user of result of verification check Feature #424 - Use messaging system for email verifification check response * uses add_message in verify_email and routes to the user page, bypassing verify_email.html --- mediagoblin/auth/views.py | 15 ++++++---- .../mediagoblin/auth/verify_email.html | 28 ------------------- 2 files changed, 10 insertions(+), 33 deletions(-) delete mode 100644 mediagoblin/templates/mediagoblin/auth/verify_email.html diff --git a/mediagoblin/auth/views.py b/mediagoblin/auth/views.py index 1d00f382..435ad803 100644 --- a/mediagoblin/auth/views.py +++ b/mediagoblin/auth/views.py @@ -18,6 +18,7 @@ import uuid from webob import exc +from mediagoblin import messages from mediagoblin.util import render_to_response, redirect from mediagoblin.db.util import ObjectId from mediagoblin.auth import lib as auth_lib @@ -124,16 +125,20 @@ def verify_email(request): if user and user['verification_key'] == unicode(request.GET['token']): user['status'] = u'active' user['email_verified'] = True - verification_successful = True user.save() + messages.add_message(request, + messages.SUCCESS, + 'Your email address has been verified. ' \ + 'You may now login!') else: - verification_successful = False + messages.add_message(request, + messages.ERROR, + 'The verification key or user id is incorrect') return render_to_response( request, - 'mediagoblin/auth/verify_email.html', - {'user': user, - 'verification_successful': verification_successful}) + 'mediagoblin/user_pages/user.html', + {'user': user}) def resend_activation(request): diff --git a/mediagoblin/templates/mediagoblin/auth/verify_email.html b/mediagoblin/templates/mediagoblin/auth/verify_email.html deleted file mode 100644 index b6e6d1f8..00000000 --- a/mediagoblin/templates/mediagoblin/auth/verify_email.html +++ /dev/null @@ -1,28 +0,0 @@ -{# -# GNU MediaGoblin -- federated, autonomous media hosting -# Copyright (C) 2011 Free Software Foundation, Inc -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -#} -{% extends "mediagoblin/base.html" %} - -{% block mediagoblin_content %} -

- {% if verification_successful %} - Your email address has been verified! - {% else %} - The verification key or user id is incorrect - {% endif %} -

-{% endblock %} From e054ae9b3dfc518a34eb4a7395b177f0e8a31469 Mon Sep 17 00:00:00 2001 From: Caleb Forbes Davis V Date: Mon, 4 Jul 2011 20:04:00 -0500 Subject: [PATCH 2/2] allows using messaging instead of verify_email.html to pass tests * re-instated verification_successful flag * modified test_auth to verify nav to user_pages/user.html template --- mediagoblin/auth/views.py | 5 ++++- mediagoblin/tests/test_auth.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mediagoblin/auth/views.py b/mediagoblin/auth/views.py index 435ad803..47707ca5 100644 --- a/mediagoblin/auth/views.py +++ b/mediagoblin/auth/views.py @@ -126,11 +126,13 @@ def verify_email(request): user['status'] = u'active' user['email_verified'] = True user.save() + verification_successful = True messages.add_message(request, messages.SUCCESS, 'Your email address has been verified. ' \ 'You may now login!') else: + verification_successful = False messages.add_message(request, messages.ERROR, 'The verification key or user id is incorrect') @@ -138,7 +140,8 @@ def verify_email(request): return render_to_response( request, 'mediagoblin/user_pages/user.html', - {'user': user}) + {'user': user, + 'verification_successful' : verification_successful}) def resend_activation(request): diff --git a/mediagoblin/tests/test_auth.py b/mediagoblin/tests/test_auth.py index 3a13cbb1..ad9dd35b 100644 --- a/mediagoblin/tests/test_auth.py +++ b/mediagoblin/tests/test_auth.py @@ -189,7 +189,7 @@ def test_register_views(test_app): "/auth/verify_email/?userid=%s&token=total_bs" % unicode( new_user['_id'])) context = util.TEMPLATE_TEST_CONTEXT[ - 'mediagoblin/auth/verify_email.html'] + 'mediagoblin/user_pages/user.html'] assert context['verification_successful'] == False new_user = mg_globals.database.User.find_one( {'username': 'happygirl'}) @@ -201,7 +201,7 @@ def test_register_views(test_app): util.clear_test_template_context() test_app.get("%s?%s" % (path, get_params)) context = util.TEMPLATE_TEST_CONTEXT[ - 'mediagoblin/auth/verify_email.html'] + 'mediagoblin/user_pages/user.html'] assert context['verification_successful'] == True new_user = mg_globals.database.User.find_one( {'username': 'happygirl'})