categories: remove duplicated category code (#57965)
This commit is contained in:
parent
6479656b2d
commit
4a8931ef61
|
@ -28,11 +28,6 @@ import wcs.admin.categories
|
|||
|
||||
|
||||
class CategoryUI(wcs.admin.categories.CategoryUI):
|
||||
def __init__(self, category):
|
||||
self.category = category
|
||||
if self.category is None:
|
||||
self.category = Category()
|
||||
|
||||
def get_form(self, **kwargs):
|
||||
form = super().get_form(**kwargs)
|
||||
homepage_redirect_url = get_cfg('misc', {}).get('homepage-redirect-url')
|
||||
|
@ -69,35 +64,10 @@ class CategoryUI(wcs.admin.categories.CategoryUI):
|
|||
|
||||
|
||||
class CategoryPage(wcs.admin.categories.CategoryPage):
|
||||
def __init__(self, component):
|
||||
self.category = Category.get(component)
|
||||
self.category_ui = CategoryUI(self.category)
|
||||
get_response().breadcrumb.append((component + '/', self.category.name))
|
||||
category_ui_class = CategoryUI
|
||||
|
||||
|
||||
class CategoriesDirectory(wcs.admin.categories.CategoriesDirectory):
|
||||
label = N_('Categories')
|
||||
|
||||
def new(self):
|
||||
get_response().breadcrumb.append(('new', _('New')))
|
||||
category_ui = CategoryUI(None)
|
||||
form = category_ui.get_form()
|
||||
if form.get_widget('cancel').parse():
|
||||
return redirect('.')
|
||||
|
||||
if form.is_submitted() and not form.has_errors():
|
||||
try:
|
||||
category_ui.submit_form(form)
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
return redirect('.')
|
||||
|
||||
html_top('categories', title=_('New Category'))
|
||||
r = TemplateIO(html=True)
|
||||
r += htmltext('<h2>%s</h2>') % _('New Category')
|
||||
r += form.render()
|
||||
return r.getvalue()
|
||||
|
||||
def _q_lookup(self, component):
|
||||
return CategoryPage(component)
|
||||
category_ui_class = CategoryUI
|
||||
category_page_class = CategoryPage
|
||||
|
|
Reference in New Issue