Add ability to view details (i.e. all fields) of a batch row.
This commit is contained in:
parent
be41d0bb1e
commit
8285993fa6
10
tailbone/templates/batch/row.view.mako
Normal file
10
tailbone/templates/batch/row.view.mako
Normal file
|
@ -0,0 +1,10 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/crud.mako" />
|
||||
|
||||
<%def name="title()">${batch_display} Row</%def>
|
||||
|
||||
<%def name="context_menu_items()">
|
||||
<li>${h.link_to("Back to {0}".format(batch_display), url('{0}.view'.format(route_prefix), uuid=row.batch_uuid))}</li>
|
||||
</%def>
|
||||
|
||||
${parent.body()}
|
3
tailbone/templates/vendors/invoices/row.view.mako
vendored
Normal file
3
tailbone/templates/vendors/invoices/row.view.mako
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/batch/row.view.mako" />
|
||||
${parent.body()}
|
|
@ -147,10 +147,19 @@ class BatchGrid(BaseGrid):
|
|||
def mapped_class(self):
|
||||
return self.batch_class
|
||||
|
||||
@property
|
||||
def batch_display(self):
|
||||
"""
|
||||
Singular display text for the batch type, e.g. "Vendor Invoice".
|
||||
Override this as necessary.
|
||||
"""
|
||||
return self.batch_class.__name__
|
||||
|
||||
@property
|
||||
def batch_display_plural(self):
|
||||
"""
|
||||
Plural display text for the batch type.
|
||||
Plural display text for the batch type, e.g. "Vendor Invoices".
|
||||
Override this as necessary.
|
||||
"""
|
||||
return "{0}s".format(self.batch_display)
|
||||
|
||||
|
@ -311,6 +320,13 @@ class BaseCrud(CrudView):
|
|||
"""
|
||||
flash = {}
|
||||
|
||||
@property
|
||||
def home_route(self):
|
||||
"""
|
||||
The "home" route for the batch type, i.e. its grid view.
|
||||
"""
|
||||
return self.route_prefix
|
||||
|
||||
@property
|
||||
def permission_prefix(self):
|
||||
"""
|
||||
|
@ -362,13 +378,6 @@ class BatchCrud(BaseCrud):
|
|||
"""
|
||||
return self.route_prefix
|
||||
|
||||
@property
|
||||
def home_route(self):
|
||||
"""
|
||||
The "home" route for the batch type, i.e. its grid view.
|
||||
"""
|
||||
return self.route_prefix
|
||||
|
||||
@property
|
||||
def batch_display_plural(self):
|
||||
"""
|
||||
|
@ -780,12 +789,26 @@ class BatchRowGrid(BaseGrid):
|
|||
return '{0}.{1}'.format(self.mapped_class.__name__.lower(),
|
||||
self.request.matchdict['uuid'])
|
||||
|
||||
@property
|
||||
def batch_class(self):
|
||||
"""
|
||||
Model class of the batch to which the rows belong.
|
||||
"""
|
||||
return self.row_class.__batch_class__
|
||||
|
||||
@property
|
||||
def batch_display(self):
|
||||
"""
|
||||
Singular display text for the batch type, e.g. "Vendor Invoice".
|
||||
Override this as necessary.
|
||||
"""
|
||||
return self.batch_class.__name__
|
||||
|
||||
def current_batch(self):
|
||||
"""
|
||||
Return the current batch, based on the UUID within the URL.
|
||||
"""
|
||||
batch_class = self.row_class.__batch_class__
|
||||
return Session.query(batch_class).get(self.request.matchdict['uuid'])
|
||||
return Session.query(self.batch_class).get(self.request.matchdict['uuid'])
|
||||
|
||||
def modify_query(self, q):
|
||||
q = super(BatchRowGrid, self).modify_query(q)
|
||||
|
@ -849,8 +872,8 @@ class BatchRowGrid(BaseGrid):
|
|||
self.configure_grid(g)
|
||||
|
||||
batch = self.current_batch()
|
||||
# g.viewable = True
|
||||
# g.view_route_name = '{0}.rows.view'.format(self.route_prefix)
|
||||
g.viewable = True
|
||||
g.view_route_name = '{0}.row.view'.format(self.route_prefix)
|
||||
# TODO: Fix this check for edit mode.
|
||||
edit_mode = self.request.referrer.endswith('/edit')
|
||||
if edit_mode and not batch.executed and self.request.has_perm('{0}.edit'.format(self.permission_prefix)):
|
||||
|
@ -922,6 +945,33 @@ class BatchRowCrud(BaseCrud):
|
|||
def mapped_class(self):
|
||||
return self.row_class
|
||||
|
||||
@property
|
||||
def batch_class(self):
|
||||
"""
|
||||
Model class of the batch to which the rows belong.
|
||||
"""
|
||||
return self.row_class.__batch_class__
|
||||
|
||||
@property
|
||||
def batch_display(self):
|
||||
"""
|
||||
Singular display text for the batch type, e.g. "Vendor Invoice".
|
||||
Override this as necessary.
|
||||
"""
|
||||
return self.batch_class.__name__
|
||||
|
||||
def template_kwargs(self, form):
|
||||
"""
|
||||
Add batch row instance etc. to template context.
|
||||
"""
|
||||
row = form.fieldset.model
|
||||
return {
|
||||
'row': row,
|
||||
'batch_display': self.batch_display,
|
||||
'route_prefix': self.route_prefix,
|
||||
'permission_prefix': self.permission_prefix,
|
||||
}
|
||||
|
||||
def delete(self):
|
||||
"""
|
||||
"Delete" a row from the batch. This sets the ``removed`` flag on the
|
||||
|
@ -1003,6 +1053,12 @@ def defaults(config, batch_grid, batch_crud, row_grid, row_crud, url_prefix,
|
|||
renderer='/batch/rows.mako',
|
||||
permission='{0}.view'.format(permission_prefix))
|
||||
|
||||
# view batch row
|
||||
config.add_route('{0}.row.view'.format(route_prefix), '{0}row/{{uuid}}'.format(url_prefix))
|
||||
config.add_view(row_crud, attr='read', route_name='{0}.row.view'.format(route_prefix),
|
||||
renderer='{0}/row.view.mako'.format(template_prefix),
|
||||
permission='{0}.view'.format(permission_prefix))
|
||||
|
||||
# Bulk delete batch rows
|
||||
config.add_route('{0}.rows.bulk_delete'.format(route_prefix), '{0}{{uuid}}/rows/delete'.format(url_prefix))
|
||||
config.add_view(row_grid, attr='bulk_delete', route_name='{0}.rows.bulk_delete'.format(route_prefix),
|
||||
|
|
1
tailbone/views/vendors/invoices.py
vendored
1
tailbone/views/vendors/invoices.py
vendored
|
@ -198,6 +198,7 @@ class VendorInvoiceRowGrid(BatchRowGrid):
|
|||
class VendorInvoiceRowCrud(BatchRowCrud):
|
||||
row_class = VendorInvoiceRow
|
||||
route_prefix = 'vendors.invoices'
|
||||
batch_display = "Vendor Invoice"
|
||||
|
||||
|
||||
def includeme(config):
|
||||
|
|
Loading…
Reference in a new issue