You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by gc...@apache.org on 2022/02/15 22:53:39 UTC
[allura] 01/01: #8412 added new method default_redirect
This is an automated email from the ASF dual-hosted git repository.
gcruz pushed a commit to branch gc/8412
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 7ef4254949d0fb720e15fdf4abb3dd5e86352782
Author: Guillermo Cruz <gu...@slashdotmedia.com>
AuthorDate: Tue Feb 15 15:53:32 2022 -0700
#8412 added new method default_redirect
---
Allura/allura/app.py | 7 +++++++
Allura/allura/controllers/project.py | 4 +++-
Allura/allura/model/project.py | 4 ++--
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index 9d57e17..8446fd4 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -805,6 +805,13 @@ class Application(object):
with open(attachment_path.encode('utf8', 'replace'), 'wb') as fl:
fl.write(attachment.rfile().read())
+ def default_redirect(self):
+ """Redirect to url if first tool in a project. This method raises a
+ redirect exception.
+
+ """
+ return None
+
class AdminControllerMixin(object):
"""Provides common functionality admin controllers need"""
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index 57133ff..3c1983a 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -399,9 +399,11 @@ class ProjectController(FeedController):
@expose()
@with_trailing_slash
def index(self, **kw):
- mount = c.project.first_mount_visible(c.user)
+ mount, app = c.project.first_mount_visible(c.user)
activity_enabled = asbool(config.get('activitystream.enabled', False))
if mount is not None:
+ if hasattr(app, 'default_redirect'):
+ return app.default_redirect()
if 'ac' in mount:
redirect(mount['ac'].options.mount_point + '/')
elif 'sub' in mount:
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 1c2afe3..8dbb3d5 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -975,11 +975,11 @@ class Project(SearchIndexable, MappedClass, ActivityNode, ActivityObject):
if 'sub' in mount:
sub = mount['sub']
if has_access(sub, 'read', user):
- return mount
+ return mount, sub
elif 'ac' in mount:
app = self.app_instance(mount['ac'])
if app.is_visible_to(user):
- return mount
+ return mount, app
return None
def next_mount_point(self, include_hidden=False):