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 2016/07/01 19:38:07 UTC
[1/2] allura git commit: [#8078] reduce delays for suggesting and
validating project names
Repository: allura
Updated Branches:
refs/heads/db/8078 91a0f5628 -> b4c9652e7
[#8078] reduce delays for suggesting and validating project names
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/102a54e0
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/102a54e0
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/102a54e0
Branch: refs/heads/db/8078
Commit: 102a54e0d54155e1dccaaa25c903aee04a797a65
Parents: 91a0f56
Author: Dave Brondsema <da...@brondsema.net>
Authored: Fri Jul 1 11:35:09 2016 -0400
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Fri Jul 1 11:35:09 2016 -0400
----------------------------------------------------------------------
Allura/allura/controllers/project.py | 6 ----
Allura/allura/lib/plugin.py | 9 ------
Allura/allura/lib/widgets/forms.py | 29 ++++++++------------
.../tests/functional/test_neighborhood.py | 6 ----
Allura/allura/tests/test_plugin.py | 8 ------
5 files changed, 12 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/102a54e0/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index 9fe1177..d2039a7 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -183,12 +183,6 @@ class NeighborhoodController(object):
return res
@expose('json:')
- def suggest_name(self, project_name='', **kw):
- provider = plugin.ProjectRegistrationProvider.get()
- return dict(suggested_name=provider.suggest_name(project_name,
- self.neighborhood))
-
- @expose('json:')
@validate(W.add_project)
def check_names(self, **raw_data):
return c.form_errors
http://git-wip-us.apache.org/repos/asf/allura/blob/102a54e0/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 64b44b3..06242c4 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -681,15 +681,6 @@ class ProjectRegistrationProvider(object):
method = config.get('registration.method', 'local')
return app_globals.Globals().entry_points['registration'][method]()
- def suggest_name(self, project_name, neighborhood):
- """Return a suggested project shortname for the full ``project_name``.
-
- Example: "My Great Project" -> "mygreatproject"
-
- """
- name = re.sub("[^A-Za-z0-9]", " ", project_name).lower()
- return '-'.join(name.split())
-
def rate_limit(self, user, neighborhood):
"""Check the various config-defined project registration rate
limits, and if any are exceeded, raise ProjectRatelimitError.
http://git-wip-us.apache.org/repos/asf/allura/blob/102a54e0/Allura/allura/lib/widgets/forms.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index fbff6d4..0820117 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -1025,6 +1025,9 @@ class NeighborhoodAddProjectForm(ForgeForm):
});
}
});
+ var suggest_name = function(project_name) {
+ return project_name.replace(/[^A-Za-z0-9]+/g, '-').toLowerCase();
+ };
var check_names = function() {
var data = {
'neighborhood': $nbhd_input.val(),
@@ -1037,28 +1040,20 @@ class NeighborhoodAddProjectForm(ForgeForm):
});
};
var manual = false;
- $name_input.keyup(function(){
- delay(function() {
- if (!manual) {
- var data = {
- 'project_name':$name_input.val()
- };
- $.getJSON('suggest_name', data, function(result){
- $unixname_input.val(result.suggested_name);
- $url_fragment.text(result.suggested_name);
- check_names();
- });
- } else {
- check_names();
- }
- }, 500);
+ $name_input.on('input', function(){
+ if (!manual) {
+ var suggested_name = suggest_name($name_input.val());
+ $unixname_input.val(suggested_name);
+ $url_fragment.text(suggested_name);
+ }
+ delay(check_names, 20);
});
$unixname_input.change(function() {
manual = true;
});
- $unixname_input.keyup(function(){
+ $unixname_input.on('input', function(){
$url_fragment.text($unixname_input.val());
- delay(check_names, 500);
+ delay(check_names, 20);
});
});
''' % dict(neighborhood=neighborhood, project_name=project_name, project_unixname=project_unixname))
http://git-wip-us.apache.org/repos/asf/allura/blob/102a54e0/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 1119749..ce8c8d8 100644
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -821,12 +821,6 @@ class TestNeighborhood(TestController):
assert r.html.find('div', id='top_nav').find(
'a', href='/adobe/testtemp/admin/'), r.html
- def test_name_suggest(self):
- r = self.app.get('/p/suggest_name?project_name=My+Moz')
- assert_equal(r.json, dict(suggested_name='my-moz'))
- r = self.app.get('/p/suggest_name?project_name=Te%st!')
- assert_equal(r.json, dict(suggested_name='te-st'))
-
def test_name_check(self):
for name in ('My+Moz', 'Te%st!', 'ab', 'a' * 16):
r = self.app.get(
http://git-wip-us.apache.org/repos/asf/allura/blob/102a54e0/Allura/allura/tests/test_plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_plugin.py b/Allura/allura/tests/test_plugin.py
index 1cbd686..a30c66e 100644
--- a/Allura/allura/tests/test_plugin.py
+++ b/Allura/allura/tests/test_plugin.py
@@ -65,14 +65,6 @@ class TestProjectRegistrationProvider(object):
private_project=False,
)
- def test_suggest_name(self):
- f = self.provider.suggest_name
- assert_equals(f('Foo Bar', Mock()), 'foo-bar')
- assert_equals(f('A More Than Fifteen Character Name', Mock()),
- 'a-more-than-fifteen-character-name')
- assert_equals(f('foo! bar?.. the great!!', Mock()),
- 'foo-bar-the-great')
-
@patch('allura.model.Project')
def test_shortname_validator(self, Project):
Project.query.get.return_value = None
[2/2] allura git commit: [#8078] use a login overlay on project
creation form
Posted by br...@apache.org.
[#8078] use a login overlay on project creation form
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/b4c9652e
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/b4c9652e
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/b4c9652e
Branch: refs/heads/db/8078
Commit: b4c9652e7ac1fc152d233d1d49a276860e0efe3a
Parents: 102a54e
Author: Dave Brondsema <da...@brondsema.net>
Authored: Fri Jul 1 15:38:00 2016 -0400
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Fri Jul 1 15:38:00 2016 -0400
----------------------------------------------------------------------
Allura/allura/controllers/project.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/b4c9652e/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index d2039a7..ee0927b 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -144,7 +144,8 @@ class NeighborhoodController(object):
@expose('jinja:allura:templates/neighborhood_add_project.html')
@without_trailing_slash
def add_project(self, **form_data):
- require_access(self.neighborhood, 'register')
+ with h.login_overlay():
+ require_access(self.neighborhood, 'register')
verify = c.form_errors == {'_the_form': u'phone-verification'}
c.show_phone_verification_overlay = verify
c.add_project = W.add_project