def submitnew(): """Form action handler for INSPIRE author new form.""" from inspire.modules.forms.utils import DataExporter from invenio.modules.workflows.models import BibWorkflowObject from flask.ext.login import current_user form = AuthorUpdateForm(formdata=request.form) visitor = DataExporter() visitor.visit(form) myobj = BibWorkflowObject.create_object(id_user=current_user.get_id()) myobj.set_data(visitor.data) # Start workflow. delayed=True will execute the workflow in the # background using, for example, Celery. myobj.start_workflow("authornew", delayed=True) return render_template('authors/forms/new_success.html')
def reviewhandler(objectid): """Form handler when a cataloger accepts an author review.""" from inspire.modules.forms.utils import DataExporter from invenio.modules.workflows.models import BibWorkflowObject if not objectid: abort(400) form = AuthorUpdateForm(formdata=request.form) visitor = DataExporter() visitor.visit(form) workflow_object = BibWorkflowObject.query.get(objectid) extra_data = workflow_object.get_extra_data() extra_data["approved"] = True extra_data["recreate_data"] = True extra_data["ticket"] = request.form.get('ticket') == "True" workflow_object.set_extra_data(extra_data) workflow_object.set_data(visitor.data) workflow_object.save() workflow_object.continue_workflow(delayed=True) return render_template('authors/forms/new_review_accepted.html', approved=True)