refactored batches.list route a bit

This commit is contained in:
Lance Edgar 2012-04-21 12:48:06 -05:00
parent 675c4deb63
commit 6bf3fd5886
9 changed files with 24 additions and 19 deletions

View file

@ -4,7 +4,7 @@
<%def name="crud_name()">Batch</%def>
<%def name="menu()">
<p>${h.link_to("Back to Batches", url('batch.list'))}</p>
<p>${h.link_to("Back to Batches", url('batches.list'))}</p>
% if fieldset.edit:
<p>${h.link_to("View Batch Details", url('batch.details', uuid=fieldset.model.uuid))}</p>
<p>${h.link_to("Execute this Batch", url('batch.execute', uuid=fieldset.model.uuid))}</p>

View file

@ -4,7 +4,7 @@
<%def name="title()">Batch : ${batch.name}</%def>
<%def name="menu()">
<p>${h.link_to("Back to Batches", url('batch.list'))}</p>
<p>${h.link_to("Back to Batches", url('batches.list'))}</p>
<p>${h.link_to("View Batch Properties", url('batch.edit', uuid=batch.uuid))}</p>
<p>${h.link_to("Execute this Batch", url('batch.execute', uuid=batch.uuid))}</p>
</%def>

View file

@ -4,7 +4,7 @@
<%def name="title()">Batch Dictionaries</%def>
<%def name="menu()">
<p>${h.link_to("Back to Batches", url('batch.list'))}</p>
<p>${h.link_to("Back to Batches", url('batches.list'))}</p>
## <p>${h.link_to("Create a New Dictionary", url('batch_dictionary'))}</p>
</%def>

View file

@ -2,7 +2,7 @@
<%inherit file="/crud.mako" />
<%def name="menu()">
<p>${h.link_to("Back to Batches", url('batch.list'))}</p>
<p>${h.link_to("Back to Batches", url('batches.list'))}</p>
<p>${h.link_to("Back to Dictionaries", url('batch_dictionaries'))}</p>
</%def>

View file

@ -2,7 +2,7 @@
<%inherit file="/crud.mako" />
<%def name="menu()">
<p>${h.link_to("Back to Batches", url('batch.list'))}</p>
<p>${h.link_to("Back to Batches", url('batches.list'))}</p>
<p>${h.link_to("Back to SIL Columns", url('sil_columns'))}</p>
</%def>

View file

@ -4,7 +4,7 @@
<%def name="title()">SIL Columns</%def>
<%def name="menu()">
<p>${h.link_to("Back to Batches", url('batch.list'))}</p>
<p>${h.link_to("Back to Batches", url('batches.list'))}</p>
</%def>
${parent.body()}

View file

@ -2,7 +2,7 @@
<%inherit file="/crud.mako" />
<%def name="menu()">
<p>${h.link_to("Back to Batches", url('batch.list'))}</p>
<p>${h.link_to("Back to Batches", url('batches.list'))}</p>
<p>${h.link_to("Back to Batch Terminals", url('batch_terminals'))}</p>
</%def>

View file

@ -4,7 +4,7 @@
<%def name="title()">Batch Terminals</%def>
<%def name="menu()">
<p>${h.link_to("Back to Batches", url('batch.list'))}</p>
<p>${h.link_to("Back to Batches", url('batches.list'))}</p>
<p>${h.link_to("Create a New Terminal", url('batch_terminal.new'))}</p>
</%def>

View file

@ -592,8 +592,10 @@ def terminals(context, request):
return grids.render_grid(request, grid, search)
@view_config(route_name='batch.list', renderer='/batches/index.mako')
def batches(context, request):
def batches(request):
"""
Batch list/index view.
"""
fmap = filters.get_filter_map(
rattail.Batch,
@ -601,7 +603,7 @@ def batches(context, request):
target=filters.filter_ilike(rattail.BatchTerminal.description))
config = filters.get_search_config(
'batches', request, fmap,
'batches.list', request, fmap,
include_filter_description=True,
filter_type_description='lk',
include_filter_source_description=True,
@ -613,7 +615,7 @@ def batches(context, request):
config, source_description="Source")
config = grids.get_grid_config(
'batches', request, search,
'batches.list', request, search,
filter_map=fmap, deletable=True, sort='target',
actions=['Execute'])
@ -642,7 +644,7 @@ def batches(context, request):
batches = grids.get_pager(query, config)
g = forms.AlchemyGrid(
rattail.Batch, batches, config,
gridurl=request.route_url('batch.list'),
gridurl=request.route_url('batches.list'),
# url_object=request.route_url('batch'),
# url_delete=request.route_url('batch'))
objurl='batch.edit', delurl='batch.delete')
@ -720,7 +722,7 @@ def batch_columns(context, request):
def batch_fieldset(batch, request):
fs = forms.make_fieldset(batch, url=request.route_url,
url_action=request.current_route_url(),
route_name='batch.list')
route_name='batches.list')
# Remove unsupported action types...for now.
enum = rattail.BATCH_ACTION_TYPE.copy()
@ -753,8 +755,8 @@ def batch_fieldset(batch, request):
return fs
@view_config(route_name='batch.edit', renderer='/batches/batch.mako')
def edit_batch(context, request):
@view_config(route_name='batch.edit', renderer='/batches/batch.mako', permission='batches.edit')
def edit_batch(request):
uuid = request.matchdict['uuid']
batch = Session.query(rattail.Batch).get(uuid) if uuid else None
assert batch
@ -786,7 +788,7 @@ def delete_batch(context, request):
assert batch
with transaction.manager:
Session.delete(batch)
return HTTPFound(location=request.route_url('batch.list'))
return HTTPFound(location=request.route_url('batches.list'))
# @view_config(route_name='batch', renderer='/batches/batch.mako')
@ -977,7 +979,7 @@ def execute(context, request):
"""
uuid = request.matchdict['uuid']
home = HTTPFound(location=request.route_url('batch.list'))
home = HTTPFound(location=request.route_url('batches.list'))
with transaction.manager:
batch = Session.query(rattail.Batch).get(uuid) if uuid else None
@ -1016,7 +1018,10 @@ def includeme(config):
config.add_route('batch_terminal.columns', '/batches/terminal/{uuid}/columns')
# config.add_route('batch_terminal', '/batches/terminal/{uuid}')
config.add_route('batch.list', '/batches')
config.add_route('batches.list', '/batches')
config.add_view(batches, route_name='batches.list', renderer='/batches/index.mako',
permission='batches.list')
# config.add_route('batch', '/batch')
# config.add_route('batch.new', '/batches/new')
config.add_route('batch.edit', '/batches/{uuid}/edit')