You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2015/07/14 17:02:49 UTC
[08/50] [abbrv] allura git commit: [#7916] better handling of
user-projects that have different names than the usernames
[#7916] better handling of user-projects that have different names than the usernames
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/48d7c563
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/48d7c563
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/48d7c563
Branch: refs/heads/ib/7897
Commit: 48d7c563f8ad72f0f72fbeae8002fbbc1b9e2a51
Parents: 338f454
Author: Dave Brondsema <da...@brondsema.net>
Authored: Thu Jul 9 15:21:48 2015 -0400
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Fri Jul 10 14:19:04 2015 +0300
----------------------------------------------------------------------
Allura/allura/controllers/project.py | 9 +++++----
Allura/allura/tests/functional/test_user_profile.py | 13 +++++++++++++
2 files changed, 18 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/48d7c563/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index 195115f..4526e62 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -105,10 +105,11 @@ class NeighborhoodController(object):
# create user-project if it is missing
user = M.User.query.get(username=pname, disabled=False, pending=False)
if user:
- project = self.neighborhood.register_project(
- plugin.AuthenticationProvider.get(
- request).user_project_shortname(user),
- user=user, user_project=True)
+ project = user.private_project()
+ if project.shortname != self.prefix + pname:
+ # might be different URL than the URL requested
+ # e.g. if username isn't valid project name and user_project_shortname() converts the name
+ redirect(project.url())
if project is None:
# look for neighborhood tools matching the URL
project = self.neighborhood.neighborhood_project
http://git-wip-us.apache.org/repos/asf/allura/blob/48d7c563/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 ffdde56..4425ace 100644
--- a/Allura/allura/tests/functional/test_user_profile.py
+++ b/Allura/allura/tests/functional/test_user_profile.py
@@ -53,6 +53,19 @@ class TestUserProfile(TestController):
assert p is not None and p.is_user_project
response = self.app.get('/u/test-user/profile/', status=404)
+ def test_differing_profile_proj_shortname(self):
+ User.upsert('foo_bar')
+
+ # default auth provider's user_project_shortname() converts _ to - for the project name
+ response = self.app.get('/u/foo_bar/profile/', status=302)
+ assert_equal(response.location, 'http://localhost/u/foo-bar/')
+
+ # unfortunately this doesn't work because the default auth provider's user_by_project_shortname()
+ # doesn't try converting back (and it probably shouldn't since you could get multiple users with conflicting proj names)
+ # at least this works with other auth providers that have a more complete implementation of both
+ # user_project_shortname() and user_by_project_shortname()
+ #self.app.get('/u/foo-bar/profile/')
+
@td.with_user_project('test-admin')
@td.with_wiki
def test_feed(self):