示例#1
0
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)
示例#2
0
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
示例#4
0
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
示例#5
0
    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
示例#6
0
    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
示例#7
0
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)
示例#8
0
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)
示例#9
0
    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
示例#10
0
    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
示例#11
0
    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
示例#12
0
    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
示例#13
0
 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
示例#14
0
 def restart(self, *args, **kwargs):
     """Resume execution from current task/callback in workflow."""
     return resume.delay(oid=self.model.id, restart_point="restart_task")