Prevent user from adding new rows to batch which has already been executed
This commit is contained in:
parent
a6e43d1658
commit
a51bf54e94
|
@ -332,13 +332,29 @@ class BatchMasterView(MasterView):
|
|||
|
||||
return self.render_to_response('edit', context)
|
||||
|
||||
def create_row(self):
|
||||
"""
|
||||
Only allow creating a new row if the batch hasn't yet been executed.
|
||||
"""
|
||||
batch = self.get_instance()
|
||||
if batch.executed:
|
||||
self.request.session.flash("You cannot add new rows to a batch which has been executed")
|
||||
return self.redirect(self.get_action_url('view', batch))
|
||||
return super(BatchMasterView, self).create_row()
|
||||
|
||||
def make_default_row_grid_tools(self, batch):
|
||||
if self.rows_creatable and not batch.executed:
|
||||
link = tags.link_to("Create a new {}".format(self.get_row_model_title()),
|
||||
self.get_action_url('create_row', batch))
|
||||
return HTML.tag('p', c=link)
|
||||
|
||||
def make_batch_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 make_row_grid_tools(self, batch):
|
||||
return self.make_batch_row_grid_tools(batch)
|
||||
return self.make_default_row_grid_tools(obj) + self.make_batch_row_grid_tools(batch)
|
||||
|
||||
def redirect_after_edit(self, batch):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue