diff --git a/tailbone/views/batch.py b/tailbone/views/batch.py index 15faed2a..10085602 100644 --- a/tailbone/views/batch.py +++ b/tailbone/views/batch.py @@ -46,7 +46,7 @@ from pyramid import httpexceptions from pyramid.renderers import render_to_response from pyramid.response import FileResponse from pyramid_simpleform import Form -from webhelpers.html import HTML +from webhelpers.html import HTML, tags from tailbone import forms, newgrids as grids from tailbone.db import Session @@ -319,6 +319,11 @@ class BatchMasterView(MasterView): return self.render_to_response('edit', context) + def make_row_grid_tools(self, batch): + if not batch.executed: + url = self.request.route_url('{}.delete_rows'.format(self.get_route_prefix()), uuid=batch.uuid) + return HTML.tag('p', c=tags.link_to("Delete all rows matching current search", url)) + def redirect_after_edit(self, batch): """ Redirect back to edit batch page after editing a batch, unless the @@ -701,8 +706,8 @@ class BatchMasterView(MasterView): permission='{}.create'.format(permission_prefix)) # bulk delete rows - config.add_route('{}.rows.bulk_delete'.format(route_prefix), '{}/{{uuid}}/rows/delete'.format(url_prefix)) - config.add_view(cls, attr='bulk_delete_rows', route_name='{}.rows.bulk_delete'.format(route_prefix), + config.add_route('{}.delete_rows'.format(route_prefix), '{}/{{uuid}}/rows/delete'.format(url_prefix)) + config.add_view(cls, attr='bulk_delete_rows', route_name='{}.delete_rows'.format(route_prefix), permission='{}.edit'.format(permission_prefix)) # execute batch diff --git a/tailbone/views/master.py b/tailbone/views/master.py index 04aacf5d..243d1621 100644 --- a/tailbone/views/master.py +++ b/tailbone/views/master.py @@ -175,10 +175,10 @@ class MasterView(View): } if self.has_rows: context['rows_grid'] = grid.render_complete(allow_save_defaults=False, - tools=self.make_row_grid_tools()) + tools=self.make_row_grid_tools(instance)) return self.render_to_response('view', context) - def make_row_grid_tools(self): + def make_row_grid_tools(self, instance): pass def make_row_grid(self, **kwargs):