You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2012/12/04 20:38:26 UTC

git commit: [#5342] Fixed 500 error when viewing profile for missing user

Updated Branches:
  refs/heads/cj/5342 [created] 0e24347f3


[#5342] Fixed 500 error when viewing profile for missing user

Signed-off-by: Cory Johns <jo...@geek.net>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/0e24347f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/0e24347f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/0e24347f

Branch: refs/heads/cj/5342
Commit: 0e24347f398467fac6fd3c50e1f662f6518d395d
Parents: 919f6b0
Author: Cory Johns <jo...@geek.net>
Authored: Tue Dec 4 19:38:07 2012 +0000
Committer: Cory Johns <jo...@geek.net>
Committed: Tue Dec 4 19:38:07 2012 +0000

----------------------------------------------------------------------
 Allura/allura/ext/user_profile/user_main.py        |    6 +++++-
 .../allura/tests/functional/test_user_profile.py   |    9 +++++++++
 2 files changed, 14 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0e24347f/Allura/allura/ext/user_profile/user_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/user_profile/user_main.py b/Allura/allura/ext/user_profile/user_main.py
index f4a1abd..f631fd5 100644
--- a/Allura/allura/ext/user_profile/user_main.py
+++ b/Allura/allura/ext/user_profile/user_main.py
@@ -5,6 +5,7 @@ import pkg_resources
 from pylons import c, g, request
 from formencode import validators
 from tg import expose, redirect, validate, response
+from webob import exc
 
 from allura import version
 from allura.app import Application
@@ -59,7 +60,10 @@ class UserProfileController(BaseController):
 
     @expose('jinja:allura.ext.user_profile:templates/user_index.html')
     def index(self, **kw):
-        return dict(user=c.project.user_project_of)
+        user = c.project.user_project_of
+        if not user:
+            raise exc.HTTPNotFound()
+        return dict(user=user)
     # This will be fully implemented in a future iteration
     # @expose('jinja:allura.ext.user_profile:templates/user_subscriptions.html')
     # def subscriptions(self):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0e24347f/Allura/allura/tests/functional/test_user_profile.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_user_profile.py b/Allura/allura/tests/functional/test_user_profile.py
index 4c6ebcd..fcea8b4 100644
--- a/Allura/allura/tests/functional/test_user_profile.py
+++ b/Allura/allura/tests/functional/test_user_profile.py
@@ -1,5 +1,6 @@
 from formencode.variabledecode import variable_encode
 
+from allura.model import Project, User
 from allura.tests import decorators as td
 from allura.tests import TestController
 
@@ -24,6 +25,14 @@ class TestUserProfile(TestController):
         response = self.app.get('/u/test-user/profile/')
         assert 'Email Addresses' not in response
 
+    @td.with_user_project('test-user')
+    def test_missing_user(self):
+        User.query.remove(dict(username='test-user'))
+        p = Project.query.get(shortname='u/test-user')
+        assert p is not None and p.is_user_project
+        response = self.app.get('/u/test-user/profile/', status=404)
+        assert 'Email Addresses' not in response
+
     @td.with_user_project('test-admin')
     @td.with_wiki
     def test_feed(self):