This is an automated email from the ASF dual-hosted git repository.
gcruz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
The following commit(s) were added to refs/heads/master by this push:
new df9b6a2bc [#8462] Redirect any missing tools as 301 instead of 404
df9b6a2bc is described below
commit df9b6a2bc21175c393fd813d0661ea9179455d71
Author: Kenton Taylor <[email protected]>
AuthorDate: Fri Sep 9 13:21:04 2022 +0000
[#8462] Redirect any missing tools as 301 instead of 404
---
Allura/allura/controllers/project.py | 12 ++++++++----
Allura/allura/tests/functional/test_neighborhood.py | 4 ++--
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/Allura/allura/controllers/project.py
b/Allura/allura/controllers/project.py
index 153bd347b..d8606f6cf 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -364,7 +364,12 @@ class ProjectController(FeedController):
c.project = subproject
c.app = None
return ProjectController(), remainder
- raise exc.HTTPNotFound(name)
+
+ if c.project.is_nbhd_project:
+ raise exc.HTTPNotFound(name)
+ else:
+ # if a tool under a project doesn't exist, redirect to the first
valid tool instead of 404
+ self.index()
@expose('jinja:allura:templates/members.html')
@with_trailing_slash
@@ -399,11 +404,10 @@ class ProjectController(FeedController):
if mount is not None:
if hasattr(app, 'default_redirect'):
app.default_redirect()
- # 301 redirect for user profiles only
- args = dict(redirect_with=exc.HTTPMovedPermanently) if
isinstance(app, UserProfileApp) else dict()
+ args = dict(redirect_with=exc.HTTPMovedPermanently)
redirect(app.url() if callable(app.url) else app.url, **args) #
Application has property; Subproject has method
else:
- redirect(c.project.app_configs[0].url())
+ redirect(c.project.app_configs[0].url(),
redirect_with=exc.HTTPMovedPermanently)
def get_feed(self, project, app, user):
"""Return a :class:`allura.controllers.feed.FeedArgs` object describing
diff --git a/Allura/allura/tests/functional/test_neighborhood.py
b/Allura/allura/tests/functional/test_neighborhood.py
index a60820621..038fb21c8 100644
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -861,8 +861,8 @@ class TestNeighborhood(TestController):
def test_neighborhood_project(self):
self.app.get('/adobe/adobe-1/admin/', status=200)
self.app.get('/p/test/sub1/wiki/')
- self.app.get('/p/test/sub1/', status=302)
- self.app.get('/p/test/no-such-app/', status=404)
+ self.app.get('/p/test/sub1/', status=301)
+ self.app.get('/p/test/no-such-app/', status=301)
def test_neighborhood_namespace(self):
# p/test exists, so try creating adobe/test