update category views
This commit is contained in:
parent
fd19661132
commit
1c280f8062
|
@ -1,2 +0,0 @@
|
|||
<%inherit file="/base.mako" />
|
||||
${parent.body()}
|
|
@ -1,10 +1,12 @@
|
|||
<%inherit file="/categories/base.mako" />
|
||||
<%inherit file="/crud.mako" />
|
||||
|
||||
<%def name="crud_name()">Category</%def>
|
||||
|
||||
<%def name="context_menu_items()">
|
||||
<li>${h.link_to("Back to Categories", url('categories.list'))}</li>
|
||||
<li>${h.link_to("Back to Categories", url('categories'))}</li>
|
||||
% if form.readonly:
|
||||
<li>${h.link_to("Edit this Category", url('category.update', uuid=form.fieldset.model.uuid))}</li>
|
||||
% elif form.updating:
|
||||
<li>${h.link_to("View this Category", url('category.read', uuid=form.fieldset.model.uuid))}</li>
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
${parent.body()}
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
<%inherit file="/categories/crud.mako" />
|
||||
${parent.body()}
|
|
@ -1,11 +1,10 @@
|
|||
<%inherit file="/categories/base.mako" />
|
||||
<%inherit file="/index.mako" />
|
||||
<%inherit file="/grid.mako" />
|
||||
|
||||
<%def name="title()">Categories</%def>
|
||||
|
||||
<%def name="context_menu_items()">
|
||||
% if request.has_perm('categories.create'):
|
||||
<li>${h.link_to("Create a new Category", url('category.new'))}</li>
|
||||
<li>${h.link_to("Create a new Category", url('category.create'))}</li>
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
<%inherit file="/categories/crud.mako" />
|
||||
${parent.body()}
|
|
@ -26,55 +26,55 @@
|
|||
``rattail.pyramid.views.categories`` -- Category Views
|
||||
"""
|
||||
|
||||
from edbob.pyramid.views import GridView
|
||||
from edbob.pyramid.views.crud import Crud
|
||||
from edbob.pyramid.views import SearchableAlchemyGridView, CrudView
|
||||
|
||||
import rattail
|
||||
|
||||
|
||||
class CategoryGrid(GridView):
|
||||
class CategoriesGrid(SearchableAlchemyGridView):
|
||||
|
||||
mapped_class = rattail.Category
|
||||
route_name = 'categories.list'
|
||||
route_prefix = 'category'
|
||||
config_prefix = 'categories'
|
||||
sort = 'number'
|
||||
|
||||
def filter_map(self):
|
||||
return self.make_filter_map(
|
||||
exact=['number'],
|
||||
ilike=['name'])
|
||||
return self.make_filter_map(exact=['number'], ilike=['name'])
|
||||
|
||||
def search_config(self, fmap):
|
||||
return self.make_search_config(
|
||||
fmap,
|
||||
def filter_config(self):
|
||||
return self.make_filter_config(
|
||||
include_filter_name=True,
|
||||
filter_type_name='lk')
|
||||
|
||||
def grid_config(self, search, fmap):
|
||||
return self.make_grid_config(search, fmap,
|
||||
sort='number')
|
||||
|
||||
def sort_map(self):
|
||||
return self.make_sort_map('number', 'name')
|
||||
|
||||
def grid(self, data, config):
|
||||
g = self.make_grid(data, config)
|
||||
def grid(self):
|
||||
g = self.make_grid()
|
||||
g.configure(
|
||||
include=[
|
||||
g.number,
|
||||
g.name,
|
||||
],
|
||||
readonly=True)
|
||||
if self.request.has_perm('categories.read'):
|
||||
g.clickable = True
|
||||
g.click_route_name = 'category.read'
|
||||
if self.request.has_perm('categories.update'):
|
||||
g.editable = True
|
||||
g.edit_route_name = 'category.update'
|
||||
if self.request.has_perm('categories.delete'):
|
||||
g.deletable = True
|
||||
g.delete_route_name = 'category.delete'
|
||||
return g
|
||||
|
||||
|
||||
class CategoryCrud(Crud):
|
||||
class CategoryCrud(CrudView):
|
||||
|
||||
mapped_class = rattail.Category
|
||||
home_route = 'categories.list'
|
||||
url_prefix = '/categories'
|
||||
home_route = 'categories'
|
||||
|
||||
def fieldset(self, obj):
|
||||
fs = self.make_fieldset(obj)
|
||||
def fieldset(self, model):
|
||||
fs = self.make_fieldset(model)
|
||||
fs.configure(
|
||||
include=[
|
||||
fs.number,
|
||||
|
@ -84,5 +84,27 @@ class CategoryCrud(Crud):
|
|||
|
||||
|
||||
def includeme(config):
|
||||
CategoryGrid.add_route(config, 'categories.list', '/categories')
|
||||
CategoryCrud.add_routes(config)
|
||||
|
||||
config.add_route('categories', '/categories')
|
||||
config.add_view(CategoriesGrid, route_name='categories',
|
||||
renderer='/categories/index.mako',
|
||||
permission='categories.list')
|
||||
|
||||
config.add_route('category.create', '/categories/new')
|
||||
config.add_view(CategoryCrud, attr='create', route_name='category.create',
|
||||
renderer='/categories/crud.mako',
|
||||
permission='categories.create')
|
||||
|
||||
config.add_route('category.read', '/categories/{uuid}')
|
||||
config.add_view(CategoryCrud, attr='read', route_name='category.read',
|
||||
renderer='/categories/crud.mako',
|
||||
permission='categories.read')
|
||||
|
||||
config.add_route('category.update', '/categories/{uuid}/edit')
|
||||
config.add_view(CategoryCrud, attr='update', route_name='category.update',
|
||||
renderer='/categories/crud.mako',
|
||||
permission='categories.update')
|
||||
|
||||
config.add_route('category.delete', '/categories/{uuid}/delete')
|
||||
config.add_view(CategoryCrud, attr='delete', route_name='category.delete',
|
||||
permission='categories.delete')
|
||||
|
|
Loading…
Reference in a new issue