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 2020/10/26 20:13:26 UTC
[allura] 01/02: Add permit_legacy flag to
NeighborhoodProjectShortNameValidator in case a site has older names to
allow during URL checks
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch db/shortname_legacy
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 2974afb6d1e6267f077a50b4303d7a349ace33b1
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Mon Oct 26 16:08:48 2020 -0400
Add permit_legacy flag to NeighborhoodProjectShortNameValidator in case a site has older names to allow during URL checks
---
Allura/allura/controllers/rest.py | 2 +-
Allura/allura/lib/widgets/forms.py | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Allura/allura/controllers/rest.py b/Allura/allura/controllers/rest.py
index 24ee77d..db7c4a1 100644
--- a/Allura/allura/controllers/rest.py
+++ b/Allura/allura/controllers/rest.py
@@ -317,7 +317,7 @@ def nbhd_lookup_first_path(nbhd, name, current_user, remainder, api=False):
raise exc.HTTPNotFound
provider = plugin.ProjectRegistrationProvider.get()
try:
- provider.shortname_validator.to_python(pname, check_allowed=False, neighborhood=nbhd)
+ provider.shortname_validator.to_python(pname, check_allowed=False, neighborhood=nbhd, permit_legacy=True)
except Invalid:
project = None
else:
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 507ea41..2374e19 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -58,7 +58,7 @@ class _HTMLExplanation(ew.InputField):
class NeighborhoodProjectShortNameValidator(fev.FancyValidator):
- def _validate_shortname(self, shortname, neighborhood, state):
+ def _validate_shortname(self, shortname, neighborhood, state, permit_legacy=False):
if not h.re_project_name.match(shortname):
raise forge_exc.ProjectShortnameInvalid(
'Please use 3-15 small letters, numbers, and dashes.',
@@ -72,7 +72,7 @@ class NeighborhoodProjectShortNameValidator(fev.FancyValidator):
'This project name is taken.',
shortname, state)
- def to_python(self, value, state=None, check_allowed=True, neighborhood=None):
+ def to_python(self, value, state=None, check_allowed=True, neighborhood=None, permit_legacy=False):
"""
Validate a project shortname.
@@ -83,7 +83,7 @@ class NeighborhoodProjectShortNameValidator(fev.FancyValidator):
if neighborhood is None:
neighborhood = M.Neighborhood.query.get(name=state.full_dict['neighborhood'])
value = h.really_unicode(value or '')
- self._validate_shortname(value, neighborhood, state)
+ self._validate_shortname(value, neighborhood, state, permit_legacy=permit_legacy)
if check_allowed:
self._validate_allowed(value, neighborhood, state)
return value