Let a batch disallow bulk-deletion of its rows

This commit is contained in:
Lance Edgar 2017-05-04 16:34:48 -05:00
parent 2c14dce30d
commit 72ae1191a0
2 changed files with 8 additions and 6 deletions

View file

@ -386,7 +386,7 @@ class BatchMasterView(MasterView):
return HTML.tag('p', c=link) return HTML.tag('p', c=link)
def make_batch_row_grid_tools(self, batch): def make_batch_row_grid_tools(self, batch):
if not batch.executed and self.request.has_perm('{}.delete_rows'.format(self.get_permission_prefix())): if self.rows_bulk_deletable and not batch.executed and self.request.has_perm('{}.delete_rows'.format(self.get_permission_prefix())):
url = self.request.route_url('{}.delete_rows'.format(self.get_route_prefix()), uuid=batch.uuid) 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)) return HTML.tag('p', c=tags.link_to("Delete all rows matching current search", url))
@ -881,11 +881,12 @@ class BatchMasterView(MasterView):
"Refresh data for {}".format(model_title)) "Refresh data for {}".format(model_title))
# bulk delete rows # bulk delete rows
config.add_route('{}.delete_rows'.format(route_prefix), '{}/{{uuid}}/rows/delete'.format(url_prefix)) if cls.rows_bulk_deletable:
config.add_view(cls, attr='bulk_delete_rows', route_name='{}.delete_rows'.format(route_prefix), config.add_route('{}.delete_rows'.format(route_prefix), '{}/{{uuid}}/rows/delete'.format(url_prefix))
permission='{}.delete_rows'.format(permission_prefix)) config.add_view(cls, attr='bulk_delete_rows', route_name='{}.delete_rows'.format(route_prefix),
config.add_tailbone_permission(permission_prefix, '{}.delete_rows'.format(permission_prefix), permission='{}.delete_rows'.format(permission_prefix))
"Bulk-delete data rows from {}".format(model_title)) config.add_tailbone_permission(permission_prefix, '{}.delete_rows'.format(permission_prefix),
"Bulk-delete data rows from {}".format(model_title))
# execute batch # execute batch
config.add_route('{}.execute'.format(route_prefix), '{}/{{uuid}}/execute'.format(url_prefix)) config.add_route('{}.execute'.format(route_prefix), '{}/{{uuid}}/execute'.format(url_prefix))

View file

@ -84,6 +84,7 @@ class MasterView(View):
rows_creatable = False rows_creatable = False
rows_editable = False rows_editable = False
rows_deletable = False rows_deletable = False
rows_bulk_deletable = False
@property @property
def Session(self): def Session(self):