You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by ke...@apache.org on 2019/02/13 23:13:59 UTC

[allura] branch master updated (94dbc10 -> 0fc5bca)

This is an automated email from the ASF dual-hosted git repository.

kentontaylor pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git.


    from 94dbc10  Update our git repo URL
     new 921681e  [#8268] limit categories on userstats to "Topic" trove
     new 3d001c6  [#8268] add confirmation before deleting a trove category
     new 0fc5bca  [#8268] relax category shortname uniqueness to per-trove-type

The 3 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.


Summary of changes:
 Allura/allura/controllers/trovecategories.py       | 25 ++++++++++++++--------
 Allura/allura/lib/widgets/forms.py                 |  4 ++--
 Allura/allura/templates/trovecategories.html       | 11 ++++++++++
 .../forgeuserstats/controllers/userstats.py        | 17 ++++++++++-----
 4 files changed, 41 insertions(+), 16 deletions(-)


[allura] 01/03: [#8268] limit categories on userstats to "Topic" trove

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 921681e44bf6b8ce33541e5cdc9bf9d3c1463c20
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Fri Feb 8 17:09:01 2019 -0500

    [#8268] limit categories on userstats to "Topic" trove
---
 ForgeUserStats/forgeuserstats/controllers/userstats.py | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/ForgeUserStats/forgeuserstats/controllers/userstats.py b/ForgeUserStats/forgeuserstats/controllers/userstats.py
index 6194257..ffd2e58 100644
--- a/ForgeUserStats/forgeuserstats/controllers/userstats.py
+++ b/ForgeUserStats/forgeuserstats/controllers/userstats.py
@@ -14,18 +14,23 @@
 #       KIND, either express or implied.  See the License for the
 #       specific language governing permissions and limitations
 #       under the License.
+from datetime import datetime
+import re
 
 from tg import expose, validate, redirect
 from tg.decorators import with_trailing_slash
-from datetime import datetime
+from pylons import tmpl_context as c
+from webob import exc
+
 from allura.controllers import BaseController
 import allura.model as M
-from forgeuserstats.model.stats import UserStats
-from pylons import tmpl_context as c
 from allura.lib.security import require_access
-from forgeuserstats.widgets.forms import StatsPreferencesForm
 from allura.lib.decorators import require_post
 
+from forgeuserstats.model.stats import UserStats
+from forgeuserstats.widgets.forms import StatsPreferencesForm
+
+
 stats_preferences_form = StatsPreferencesForm()
 
 
@@ -33,7 +38,9 @@ class ForgeUserStatsCatController(BaseController):
 
     @expose()
     def _lookup(self, category, *remainder):
-        cat = M.TroveCategory.query.get(shortname=category)
+        cat = M.TroveCategory.query.get(shortname=category, fullpath=re.compile(r'^Topic :: '))
+        if not cat:
+            raise exc.HTTPNotFound
         return ForgeUserStatsCatController(category=cat), remainder
 
     def __init__(self, category=None):


[allura] 02/03: [#8268] add confirmation before deleting a trove category

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 3d001c6c6ecf9b9423bc3fa5957043e2af74dfc2
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Fri Feb 8 17:18:06 2019 -0500

    [#8268] add confirmation before deleting a trove category
---
 Allura/allura/templates/trovecategories.html | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/Allura/allura/templates/trovecategories.html b/Allura/allura/templates/trovecategories.html
index ff7959c..f3bec8e 100644
--- a/Allura/allura/templates/trovecategories.html
+++ b/Allura/allura/templates/trovecategories.html
@@ -78,3 +78,14 @@
 
   </div>
 {% endblock %}
+
+
+{% block extra_js %}
+<script type="text/javascript">
+$(function() {
+    $("input[value=Remove]").click(function(){
+        return confirm('Are you sure?  Before you remove it, make sure no projects use this category any more.');
+    });
+});
+</script>
+{% endblock %}
\ No newline at end of file


[allura] 03/03: [#8268] relax category shortname uniqueness to per-trove-type

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 0fc5bca80232b14370f17d669109caec9c17f5b9
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Fri Feb 8 17:50:38 2019 -0500

    [#8268] relax category shortname uniqueness to per-trove-type
---
 Allura/allura/controllers/trovecategories.py | 25 ++++++++++++++++---------
 Allura/allura/lib/widgets/forms.py           |  4 ++--
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/Allura/allura/controllers/trovecategories.py b/Allura/allura/controllers/trovecategories.py
index 2e2c33f..392de1c 100644
--- a/Allura/allura/controllers/trovecategories.py
+++ b/Allura/allura/controllers/trovecategories.py
@@ -14,6 +14,7 @@
 #       KIND, either express or implied.  See the License for the
 #       specific language governing permissions and limitations
 #       under the License.
+import re
 from collections import OrderedDict
 
 from tg import expose, flash, redirect, validate, config
@@ -128,25 +129,31 @@ class TroveCategoryController(BaseController):
             [el.trove_cat_id for el in M.TroveCategory.query.find()]) + 1
         shortname = h.slugify(shortname or name)[1]
 
-        oldcat = M.TroveCategory.query.get(shortname=shortname)
+        if upper:
+            trove_type = upper.fullpath.split(' :: ')[0]
+            fullpath_re = re.compile(r'^{} :: '.format(re.escape(trove_type)))  # e.g. scope within "Topic :: "
+        else:
+            # no parent, so making a top-level.  Don't limit fullpath_re, so enforcing global uniqueness
+            fullpath_re = re.compile(r'')
+        oldcat = M.TroveCategory.query.get(shortname=shortname, fullpath=fullpath_re)
         if oldcat:
-            flash('Category "%s" with shortname "%s" already exists.  Try a different, unique shortname' % (name, shortname), "error")
+            flash('A category with shortname "%s" already exists (%s).  Try a different, unique shortname'
+                  % (shortname, oldcat.fullpath), "error")
+            redir_params = u'?categoryname={}&shortname={}'.format(name, shortname)
         else:
-            category = M.TroveCategory(
+            M.TroveCategory(
                 trove_cat_id=newid,
                 trove_parent_id=upper_id,
                 fullname=name,
                 shortname=shortname,
                 fullpath=path,
                 show_as_skill=show_as_skill)
-            if category:
-                flash('Category "%s" successfully created.' % name)
-            else:
-                flash('An error occured while crearing the category.', "error")
+            flash('Category "%s" successfully created.' % name)
+            redir_params = ''
         if upper:
-            redirect(u'/categories/{}/?categoryname={}&shortname={}'.format(upper.trove_cat_id, name, shortname))
+            redirect(u'/categories/{}/{}'.format(upper.trove_cat_id, redir_params))
         else:
-            redirect(u'/categories/?categoryname={}&shortname={}'.format(name, shortname))
+            redirect(u'/categories/{}'.format(redir_params))
 
     @expose()
     @require_post()
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index e3f8232..9c75c51 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -649,9 +649,9 @@ class AddTroveCategoryForm(ForgeForm):
             attrs={},
             validator=fev.UnicodeString(not_empty=True))
         shortname = ew.TextField(
-            label="Short Name",
+            label="Short name",
             validator=fev.UnicodeString(),
-            attrs={'placeholder': 'optional'})
+            attrs={'placeholder': 'optional; unique identifier'})
 
     def display(self, **kw):
         upper_category = kw.get('uppercategory_id', 0)