0001-admin-don-t-fail-if-category-does-not-exist-57366.patch
tests/admin_pages/test_category.py | ||
---|---|---|
95 | 95 | |
96 | 96 |
assert Category.get(1).description == 'category description' |
97 | 97 | |
98 |
app.get('/backoffice/forms/categories/foo-bar/', status=404) |
|
99 | ||
98 | 100 | |
99 | 101 |
def test_categories_edit_duplicate_name(pub): |
100 | 102 |
Category.wipe() |
wcs/admin/categories.py | ||
---|---|---|
23 | 23 |
from wcs.formdef import FormDef |
24 | 24 |
from wcs.qommon import _, misc, template |
25 | 25 |
from wcs.qommon.backoffice.menu import html_top |
26 |
from wcs.qommon.errors import AccessForbiddenError |
|
26 |
from wcs.qommon.errors import AccessForbiddenError, TraversalError
|
|
27 | 27 |
from wcs.qommon.form import Form, HtmlWidget, SingleSelectWidget, StringWidget, WidgetList, WysiwygTextWidget |
28 | 28 |
from wcs.workflows import Workflow |
29 | 29 | |
... | ... | |
163 | 163 |
do_not_call_in_templates = True |
164 | 164 | |
165 | 165 |
def __init__(self, component): |
166 |
self.category = self.category_class.get(component) |
|
166 |
try: |
|
167 |
self.category = self.category_class.get(component) |
|
168 |
except KeyError: |
|
169 |
raise TraversalError() |
|
167 | 170 |
self.category_ui = self.category_ui_class(self.category) |
168 | 171 |
get_response().breadcrumb.append((component + '/', self.category.name)) |
169 | 172 | |
170 |
- |