Fix batch action kwargs, so 'action' can be a handler kwarg

i.e. at least the handheld batch handler, accepts an 'action' kwarg for its
execute() method.  we had apparently broken that
This commit is contained in:
Lance Edgar 2018-07-03 18:32:03 -05:00
parent ac5a6c011b
commit 3cc789dda9

View file

@ -706,7 +706,7 @@ class BatchMasterView(MasterView):
return self.handler.get_execute_title(batch) return self.handler.get_execute_title(batch)
return "Execute Batch" return "Execute Batch"
def handler_action(self, batch, action, **kwargs): def handler_action(self, batch, batch_action, **kwargs):
""" """
View which will attempt to refresh all data for the batch. What View which will attempt to refresh all data for the batch. What
exactly this means will depend on the type of batch etc. exactly this means will depend on the type of batch etc.
@ -718,11 +718,11 @@ class BatchMasterView(MasterView):
user_uuid = user.uuid if user else None user_uuid = user.uuid if user else None
username = user.username if user else None username = user.username if user else None
key = '{}.{}'.format(self.model_class.__tablename__, action) key = '{}.{}'.format(self.model_class.__tablename__, batch_action)
progress = SessionProgress(self.request, key) progress = SessionProgress(self.request, key)
# must ensure versioning is *disabled* during action, if handler says so # must ensure versioning is *disabled* during action, if handler says so
allow_versioning = self.handler.allow_versioning(action) allow_versioning = self.handler.allow_versioning(batch_action)
if not allow_versioning and self.rattail_config.versioning_enabled(): if not allow_versioning and self.rattail_config.versioning_enabled():
can_cancel = False can_cancel = False
@ -738,21 +738,21 @@ class BatchMasterView(MasterView):
thread.start() thread.start()
# launch thread to invoke handler action # launch thread to invoke handler action
thread = Thread(target=self.action_subprocess_thread, args=(batch.uuid, port, username, action, progress)) thread = Thread(target=self.action_subprocess_thread, args=(batch.uuid, port, username, batch_action, progress))
thread.start() thread.start()
else: # either versioning is disabled, or handler doesn't mind else: # either versioning is disabled, or handler doesn't mind
can_cancel = True can_cancel = True
# launch thread to populate batch; that will update session progress directly # launch thread to populate batch; that will update session progress directly
target = getattr(self, '{}_thread'.format(action)) target = getattr(self, '{}_thread'.format(batch_action))
thread = Thread(target=target, args=(batch.uuid, user_uuid, progress), kwargs=kwargs) thread = Thread(target=target, args=(batch.uuid, user_uuid, progress), kwargs=kwargs)
thread.start() thread.start()
return self.render_progress(progress, { return self.render_progress(progress, {
'can_cancel': can_cancel, 'can_cancel': can_cancel,
'cancel_url': self.get_action_url('view', batch), 'cancel_url': self.get_action_url('view', batch),
'cancel_msg': "{} of batch was canceled.".format(action.capitalize()), 'cancel_msg': "{} of batch was canceled.".format(batch_action.capitalize()),
}) })
def progress_thread(self, sock, success_url, progress): def progress_thread(self, sock, success_url, progress):