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 20:41:55 UTC
[1/3] allura git commit: [#8094] reduce delays for suggesting and
validating project names
Repository: allura
Updated Branches:
refs/heads/db/8094 [created] 81cfcf9aa
[#8094] 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/08b48cac
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/08b48cac
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/08b48cac
Branch: refs/heads/db/8094
Commit: 08b48cac507d422d54c67cf600a8e5e1eb180cc2
Parents: bdf758d
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 16:41:38 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/08b48cac/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/08b48cac/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/08b48cac/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/08b48cac/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/08b48cac/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
[3/3] allura git commit: [#8094] use same space for URL and error msg,
to avoid page content shifting around
Posted by br...@apache.org.
[#8094] use same space for URL and error msg, to avoid page content shifting around
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/81cfcf9a
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/81cfcf9a
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/81cfcf9a
Branch: refs/heads/db/8094
Commit: 81cfcf9aad961a6665eb8a5e2be75f81f00c51e2
Parents: 932ed27
Author: Dave Brondsema <da...@brondsema.net>
Authored: Fri Jul 1 16:19:14 2016 -0400
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Fri Jul 1 16:41:46 2016 -0400
----------------------------------------------------------------------
Allura/allura/lib/widgets/forms.py | 4 +++-
Allura/allura/lib/widgets/resources/css/add_project.css | 7 ++-----
Allura/allura/templates/widgets/neighborhood_add_project.html | 5 ++++-
Allura/allura/tests/functional/test_neighborhood.py | 6 +++---
4 files changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/81cfcf9a/Allura/allura/lib/widgets/forms.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 0820117..7bb982a 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -55,7 +55,7 @@ class NeighborhoodProjectShortNameValidator(fev.FancyValidator):
def _validate_shortname(self, shortname, neighborhood, state):
if not h.re_project_name.match(shortname):
raise forge_exc.ProjectShortnameInvalid(
- 'Please use only small letters, numbers, and dashes 3-15 characters long.',
+ 'Please use 3-15 small letters, numbers, and dashes.',
shortname, state)
def _validate_allowed(self, shortname, neighborhood, state):
@@ -976,6 +976,7 @@ class NeighborhoodAddProjectForm(ForgeForm):
var $nbhd_input = $('input[name="%(neighborhood)s"]');
var $name_input = $('input[name="%(project_name)s"]');
var $unixname_input = $('input[name="%(project_unixname)s"]');
+ var $project_url = $('#project_url');
var $url_fragment = $('#url_fragment');
var $form = $name_input.closest('form');
var delay = (function(){
@@ -1005,6 +1006,7 @@ class NeighborhoodAddProjectForm(ForgeForm):
$error_field = $('<div class="error" style="display: none"></div>').insertAfter($input);
}
$error_field.text(message).toggle(!!message);
+ $project_url.toggle(!message);
update_icon($input);
};
$form.submit(function(e) {
http://git-wip-us.apache.org/repos/asf/allura/blob/81cfcf9a/Allura/allura/lib/widgets/resources/css/add_project.css
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/css/add_project.css b/Allura/allura/lib/widgets/resources/css/add_project.css
index 594b16f..a4eac98 100644
--- a/Allura/allura/lib/widgets/resources/css/add_project.css
+++ b/Allura/allura/lib/widgets/resources/css/add_project.css
@@ -35,11 +35,12 @@ div.welcome input {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
}
-div.welcome .error, div.welcome .success {
+div.welcome .error, div.welcome .success, #project_url {
font-size: 13px;
padding: 5px;
background: none;
border: 0;
+ margin-bottom: 0;
}
div.welcome .error, .error_icon {
color: #D41326;
@@ -81,10 +82,6 @@ div.welcome div.grid-9{
div.welcome div.grid-3{
padding-top: 2px;
}
-#project_url {
- font-size: 12px;
- padding-left: 5px;
-}
#url_fragment {
font-weight: 600;
}
http://git-wip-us.apache.org/repos/asf/allura/blob/81cfcf9a/Allura/allura/templates/widgets/neighborhood_add_project.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/neighborhood_add_project.html b/Allura/allura/templates/widgets/neighborhood_add_project.html
index 68efbfd..892dcd5 100644
--- a/Allura/allura/templates/widgets/neighborhood_add_project.html
+++ b/Allura/allura/templates/widgets/neighborhood_add_project.html
@@ -37,7 +37,7 @@
</label>
</div>
<div class="grid-10">{{widget.display_field(widget.fields.project_unixname)}}
- <br/><div id="project_url">http://{{request.environ['HTTP_HOST']}}{{neighborhood.url()}}<span id="url_fragment"></span></div>
+ <div id="project_url">http://{{request.environ['HTTP_HOST']}}{{neighborhood.url()}}<span id="url_fragment"></span></div>
</div>
<div class="grid-9" style="position:relative; overflow:visible">
{{ g.icons['caution'].render(tag='b', extra_css='error_icon') }}
@@ -48,6 +48,9 @@
</div>
{% if not neighborhood.project_template %}
+ <h2 style="padding-left:20px">
+ Select the tools to use in your project. You may add or remove tools at any time.
+ </h2>
{% for opt in widget.fields.tools.options %}
{% set tool = g.entry_points["tool"][opt.html_value] %}
{% set _ctx = widget.context_for(widget.fields.tools) %}
http://git-wip-us.apache.org/repos/asf/allura/blob/81cfcf9a/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 ce8c8d8..fb48faa 100644
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -513,7 +513,7 @@ class TestNeighborhood(TestController):
antispam=True,
extra_environ=dict(username='root'))
assert r.html.find('div', {'class': 'error'}
- ).string == 'Please use only small letters, numbers, and dashes 3-15 characters long.'
+ ).string == 'Please use 3-15 small letters, numbers, and dashes.'
r = self.app.post('/adobe/register',
params=dict(
project_unixname='mymoz', project_name='My Moz',
@@ -528,7 +528,7 @@ class TestNeighborhood(TestController):
antispam=True,
extra_environ=dict(username='root'))
assert r.html.find('div', {'class': 'error'}
- ).string == 'Please use only small letters, numbers, and dashes 3-15 characters long.'
+ ).string == 'Please use 3-15 small letters, numbers, and dashes.'
r = self.app.post('/p/register',
params=dict(
project_unixname='test', project_name='Tester',
@@ -827,7 +827,7 @@ class TestNeighborhood(TestController):
'/p/check_names?neighborhood=Projects&project_unixname=%s' % name)
assert_equal(
r.json,
- {'project_unixname': 'Please use only small letters, numbers, and dashes 3-15 characters long.'})
+ {'project_unixname': 'Please use 3-15 small letters, numbers, and dashes.'})
r = self.app.get(
'/p/check_names?neighborhood=Projects&project_unixname=mymoz')
assert_equal(r.json, {})
[2/3] allura git commit: [#8094] use a login overlay on project
creation form
Posted by br...@apache.org.
[#8094] 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/932ed27b
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/932ed27b
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/932ed27b
Branch: refs/heads/db/8094
Commit: 932ed27b4abc7526ac2e19f1f45736b90dcc3610
Parents: 08b48ca
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 16:41:42 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/932ed27b/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