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 2019/02/08 22:52:28 UTC
[allura] 01/03: [#8268] limit categories on userstats to "Topic"
trove
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch db/8268
in repository https://gitbox.apache.org/repos/asf/allura.git
commit cbcbc65379aab50e744e053c008c05c50210348c
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):