You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2015/11/03 20:30:55 UTC
[3/4] allura git commit: [#7919] make _getProjectUrl and needed AJAX
urls work for nbhd-projects and subprojects
[#7919] make _getProjectUrl and needed AJAX urls work for nbhd-projects and subprojects
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/8324dd65
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/8324dd65
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/8324dd65
Branch: refs/heads/db/7919
Commit: 8324dd65cfedb61166b0384528fc5d88523d80fb
Parents: 245413a
Author: Dave Brondsema <da...@brondsema.net>
Authored: Mon Nov 2 18:41:03 2015 -0500
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Tue Nov 3 11:44:34 2015 -0500
----------------------------------------------------------------------
Allura/allura/controllers/project.py | 10 ++++++----
Allura/allura/controllers/rest.py | 6 +++++-
Allura/allura/public/nf/js/navbar.es6.js | 19 +++++++++++++++----
.../allura/tests/functional/test_neighborhood.py | 3 +++
4 files changed, 29 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/8324dd65/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index 75b1aaf..0d689a8 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -76,8 +76,9 @@ class NeighborhoodController(object):
self.neighborhood = neighborhood
self.neighborhood_name = self.neighborhood.name
self.prefix = self.neighborhood.shortname_prefix
- self.browse = NeighborhoodProjectBrowseController(
- neighborhood=self.neighborhood)
+ self.browse = NeighborhoodProjectBrowseController(neighborhood=self.neighborhood)
+ # 'admin' without underscore will pass through to _lookup which will find the regular "admin" tool mounted
+ # on the --init-- Project record for this neighborhood.
self._admin = NeighborhoodAdminController(self.neighborhood)
self._moderate = NeighborhoodModerateController(self.neighborhood)
self.import_project = ProjectImporterController(self.neighborhood)
@@ -375,17 +376,18 @@ class ToolListController(object):
class ProjectController(FeedController):
def __init__(self):
- setattr(self, '_nav.json', self._nav)
self.screenshot = ScreenshotsController()
self._list = ToolListController()
@expose('json:')
- def _nav(self):
+ def _nav(self, **kw):
return c.project.nav_data()
@expose()
def _lookup(self, name, *remainder):
name = unquote(name)
+ if name == '_nav.json':
+ return self, ['_nav']
subproject = M.Project.query.get(
shortname=c.project.shortname + '/' + name,
neighborhood_id=c.project.neighborhood_id)
http://git-wip-us.apache.org/repos/asf/allura/blob/8324dd65/Allura/allura/controllers/rest.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/rest.py b/Allura/allura/controllers/rest.py
index 30d28d9..7723c0d 100644
--- a/Allura/allura/controllers/rest.py
+++ b/Allura/allura/controllers/rest.py
@@ -281,7 +281,10 @@ class NeighborhoodRestController(object):
return rest_has_access(self._neighborhood, user, perm)
@expose()
- def _lookup(self, name, *remainder):
+ def _lookup(self, name=None, *remainder):
+
+ # TODO: make this match NeighborhoodController._lookup so that /rest/p/admin/configure_tool_grouping works
+
provider = plugin.ProjectRegistrationProvider.get()
try:
provider.shortname_validator.to_python(
@@ -291,6 +294,7 @@ class NeighborhoodRestController(object):
name = self._neighborhood.shortname_prefix + name
project = M.Project.query.get(
shortname=name, neighborhood_id=self._neighborhood._id, deleted=False)
+ log.info('nbhd rest proj=%s ... %s', project, name)
if not project:
raise exc.HTTPNotFound, name
http://git-wip-us.apache.org/repos/asf/allura/blob/8324dd65/Allura/allura/public/nf/js/navbar.es6.js
----------------------------------------------------------------------
diff --git a/Allura/allura/public/nf/js/navbar.es6.js b/Allura/allura/public/nf/js/navbar.es6.js
index f76abb7..b1d21c1 100644
--- a/Allura/allura/public/nf/js/navbar.es6.js
+++ b/Allura/allura/public/nf/js/navbar.es6.js
@@ -1,16 +1,27 @@
'use strict';
/**
- * Gets the current url.
+ * Gets the current project url.
* @constructor
* @param {bool} rest - Return a "rest" version of the url.
* @returns {string}
*/
function _getProjectUrl(rest = true) {
- var [nbhd, proj] = window.location.pathname.split('/').slice(1, 3);
- var base = `${window.location.protocol}//${window.location.host}`;
- return rest ? `${base}/rest/${nbhd}/${proj}` : `${base}/${nbhd}/${proj}`;
+ var nbhd, proj, nbhd_proj;
+ var ident_classes = document.getElementById('page-body').className.split(' ');
+ for (var cls of ident_classes) {
+ if (cls.indexOf('project-') === 0) {
+ proj = cls.slice('project-'.length);
+ }
+ }
+ nbhd = window.location.pathname.split('/')[1];
+ if (proj === '--init--') {
+ nbhd_proj = nbhd;
+ } else {
+ nbhd_proj = `${nbhd}/${proj}`;
+ }
+ return (rest ? '/rest/' : '/') + nbhd_proj;
}
function slugify(text) {
http://git-wip-us.apache.org/repos/asf/allura/blob/8324dd65/Allura/allura/tests/functional/test_neighborhood.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_neighborhood.py b/Allura/allura/tests/functional/test_neighborhood.py
index d946c7b..593a34c 100644
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -949,6 +949,9 @@ class TestNeighborhood(TestController):
assert 'View More Projects' in str(link)
assert link['href'] == '/adobe/'
+ def test_nav_json(self):
+ self.app.get('/p/_nav.json')
+
class TestPhoneVerificationOnProjectRegistration(TestController):
def test_phone_verification_fragment_renders(self):