Redirect to the user's profile after registration
authorChristopher Allan Webber <cwebber@dustycloud.org>
Fri, 29 Jul 2011 13:22:26 +0000 (08:22 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Fri, 29 Jul 2011 13:22:26 +0000 (08:22 -0500)
 - Updated the view
 - Updated the tests
 - Fixed a weirdness in the registration view where the 'user'
   variable used to be called 'entry'

mediagoblin/auth/routing.py
mediagoblin/auth/views.py
mediagoblin/tests/test_auth.py

index a50afb4890ab9e7c2cb94424c4a4f8588d4c1a09..9547b3ea58b8a750b1f9d96115353e2df157eb05 100644 (file)
@@ -19,9 +19,6 @@ from routes.route import Route
 auth_routes = [
     Route('mediagoblin.auth.register', '/register/',
           controller='mediagoblin.auth.views:register'),
-    Route('mediagoblin.auth.register_success', '/register/success/',
-          template='mediagoblin/auth/register_success.html',
-          controller='mediagoblin.views:simple_template_render'),
     Route('mediagoblin.auth.login', '/login/',
           controller='mediagoblin.auth.views:login'),
     Route('mediagoblin.auth.logout', '/logout/',
index 6f3c516544d7e9295e26afadb327ee76ce3981c9..cf07d668d90e1b65aef6cad50fe5a94c82d8a1b2 100644 (file)
@@ -55,16 +55,23 @@ def register(request):
 
         else:
             # Create the user
-            entry = request.db.User()
-            entry['username'] = request.POST['username'].lower()
-            entry['email'] = request.POST['email']
-            entry['pw_hash'] = auth_lib.bcrypt_gen_password_hash(
+            user = request.db.User()
+            user['username'] = request.POST['username'].lower()
+            user['email'] = request.POST['email']
+            user['pw_hash'] = auth_lib.bcrypt_gen_password_hash(
                 request.POST['password'])
-            entry.save(validate=True)
-
-            send_verification_email(entry, request)
-
-            return redirect(request, "mediagoblin.auth.register_success")
+            user.save(validate=True)
+
+            send_verification_email(user, request)
+
+            messages.add_message(
+                request,
+                messages.INFO,
+                ('Registration successful! '
+                 'You should get a registration email soon.'))
+            return redirect(
+                request, 'mediagoblin.user_pages.user_home',
+                user=user['username'])
 
     return render_to_response(
         request,
index ad9dd35b4906f993884b1b9c59ab0feeb42017a9..ccb9a5366ee2b2bb7b1af6e019d101b04ff88b07 100644 (file)
@@ -153,9 +153,9 @@ def test_register_views(test_app):
     ## Did we redirect to the proper page?  Use the right template?
     assert_equal(
         urlparse.urlsplit(response.location)[2],
-        '/auth/register/success/')
+        '/u/happygirl/')
     assert util.TEMPLATE_TEST_CONTEXT.has_key(
-        'mediagoblin/auth/register_success.html')
+        'mediagoblin/user_pages/user.html')
 
     ## Make sure user is in place
     new_user = mg_globals.database.User.find_one(