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:25 UTC
[allura] branch db/shortname_legacy created (now 80d618a)
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a change to branch db/shortname_legacy
in repository https://gitbox.apache.org/repos/asf/allura.git.
at 80d618a Strip leading or trailing dashes when suggesting project shortnames
This branch includes the following new commits:
new 2974afb Add permit_legacy flag to NeighborhoodProjectShortNameValidator in case a site has older names to allow during URL checks
new 80d618a Strip leading or trailing dashes when suggesting project shortnames
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[allura] 02/02: Strip leading or trailing dashes when suggesting
project shortnames
Posted by br...@apache.org.
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 80d618a4ef2863beccbf402f8c92d219f2533c83
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Mon Oct 26 16:09:09 2020 -0400
Strip leading or trailing dashes when suggesting project shortnames
---
Allura/allura/lib/widgets/forms.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 2374e19..360859a 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -1066,7 +1066,7 @@ class NeighborhoodAddProjectForm(ForgeForm):
}
});
var suggest_name = function(project_name) {
- return project_name.replace(/[^A-Za-z0-9]+/g, '-').toLowerCase();
+ return project_name.replace(/[^A-Za-z0-9]+/g, '-').toLowerCase().replace(/^-+|-+$/g, '');
};
var check_names = function() {
var data = {
[allura] 01/02: Add permit_legacy flag to
NeighborhoodProjectShortNameValidator in case a site has older names to
allow during URL checks
Posted by br...@apache.org.
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