def holdingpenreview(): """Handler for approval or rejection of new authors in Holding Pen.""" objectid = request.values.get('objectid', 0, type=int) approved = request.values.get('approved', False, type=bool) ticket = request.values.get('ticket', False, type=bool) if not objectid: abort(400) workflow_object = workflow_object_class.get(objectid) workflow_object.extra_data["approved"] = approved workflow_object.extra_data["ticket"] = ticket workflow_object.save() db.session.commit() resume.delay(workflow_object.id) return render_template('authors/forms/new_review_accepted.html', approved=approved)
def holdingpenreview(): """Handler for approval or rejection of new authors in Holding Pen.""" objectid = request.values.get('objectid', 0, type=int) approved = request.values.get('approved', False, type=bool) ticket = request.values.get('ticket', False, type=bool) if not objectid: abort(400) workflow_object = WorkflowObject.query.get(objectid) workflow_object.extra_data["approved"] = approved workflow_object.extra_data["ticket"] = ticket workflow_object.save() db.session.commit() resume.delay(workflow_object.id) return render_template('authors/forms/new_review_accepted.html', approved=approved)
def test_delayed_execution_api(app, halt_workflow): """Test continue object task.""" with app.app_context(): data = [{'foo': 'bar'}] async_result = start.delay('halttest', data) eng = WorkflowEngine.from_uuid(async_result.get()) obj = eng.processed_objects[0] assert obj.known_statuses.WAITING == obj.status assert WorkflowStatus.HALTED == eng.status obj_id = obj.id resume.delay(obj_id) obj = WorkflowObject.get(obj_id) assert obj.known_statuses.COMPLETED == obj.status
def restart_step(self, *args, **kwargs): """Restart only the current step of the workflow.""" if self.model is None: raise MissingModelError() self.workflow.status = ObjectStatus.RUNNING self.workflow.save() db.session.commit() return resume.delay( oid=self.workflow.id, restart_point="restart_task" ).id
def resume(self, *args, **kwargs): """Resume execution from next task/callback in workflow.""" if self.model is None: raise MissingModelError() if 'callback_pos' in kwargs: self.workflow.callback_pos = kwargs['callback_pos'] self.workflow.status = ObjectStatus[WorkflowStatus.RUNNING.name] self.workflow.save() db.session.commit() return resume.delay(oid=self.id, restart_point="continue_next").id
def reviewhandler(): """Form handler when a cataloger accepts an author review.""" objectid = request.values.get('objectid', 0, type=int) if not objectid: abort(400) form = AuthorUpdateForm(formdata=request.form) visitor = DataExporter() visitor.visit(form) workflow_object = workflow_object_class.get(objectid) workflow_object.extra_data["approved"] = True workflow_object.extra_data["ticket"] = request.form.get('ticket') == "True" workflow_object.extra_data['formdata'] = visitor.data workflow_object.data = formdata_to_model(workflow_object, visitor.data) workflow_object.save() db.session.commit() resume.delay(workflow_object.id) return render_template('authors/forms/new_review_accepted.html', approved=True)
def restart(self, *args, **kwargs): """Restart the whole workflow.""" if self.model is None: raise MissingModelError() self.workflow.callback_pos = [0] self.workflow.status = ObjectStatus.RUNNING self.workflow.save() db.session.commit() return resume.delay( oid=self.workflow.id, restart_point="restart_task" ).id
def resume(self, *args, **kwargs): """Resume execution from next task/callback in workflow.""" if self.model is None: raise MissingModelError() if 'callback_pos' in kwargs: self.workflow.callback_pos = kwargs['callback_pos'] self.workflow.save() db.session.commit() return resume.delay( oid=self.id, restart_point="continue_next" ).id
def restart(self, *args, **kwargs): """Restart the whole workflow. Params: callback_pos(list(int)): if passed will restart the workflow from the given callback_pos instead of restarting from scratch. """ if self.model is None: raise MissingModelError() if 'callback_pos' in kwargs: self.workflow.callback_pos = kwargs['callback_pos'] else: self.workflow.callback_pos = [0] self.workflow.status = ObjectStatus[WorkflowStatus.RUNNING.name] self.workflow.save() db.session.commit() return resume.delay(oid=self.workflow.id, restart_point="restart_task").id
def restart(self, *args, **kwargs): """Restart the whole workflow. Params: callback_pos(list(int)): if passed will restart the workflow from the given callback_pos instead of restarting from scratch. """ if self.model is None: raise MissingModelError() if 'callback_pos' in kwargs: self.workflow.callback_pos = kwargs['callback_pos'] else: self.workflow.callback_pos = [0] if 'cleanup' in kwargs: original_extra_data = self.workflow.extra_data.get( 'source_data', {}, ).get('extra_data', {}) original_data = self.workflow.extra_data.get( 'source_data', {}, ).get('data', {}) self.workflow.extra_data = original_extra_data self.workflow.data = original_data self.workflow.extra_data['source_data'] = { 'data': copy.deepcopy(original_data), 'extra_data': copy.deepcopy(original_extra_data), } self.workflow.status = ObjectStatus[WorkflowStatus.RUNNING.name] self.workflow.save() db.session.commit() return resume.delay( oid=self.workflow.id, restart_point="restart_task" ).id
def resume(self, *args, **kwargs): """Resume execution from next task/callback in workflow.""" return resume.delay( oid=self.model.id, restart_point="continue_task" ).id
def restart(self, *args, **kwargs): """Resume execution from current task/callback in workflow.""" return resume.delay(oid=self.model.id, restart_point="restart_task")