def edit_workflow(request, workflow): history = History.objects.filter(submitter=request.user, job=workflow).order_by('-submission_date') workflow_form = WorkflowForm(instance=workflow) user_can_access_job = workflow.is_accessible(request.user) user_can_edit_job = workflow.is_editable(request.user) return render( 'editor/edit_workflow.mako', request, { 'workflow_form': workflow_form, 'workflow': workflow, 'history': history, 'user_can_access_job': user_can_access_job, 'user_can_edit_job': user_can_edit_job, 'job_properties': extract_field_data(workflow_form['job_properties']), 'link_form': LinkForm(), 'default_link_form': DefaultLinkForm(action=workflow.start), 'node_form': NodeForm(), 'action_forms': [(node_type, design_form_by_type(node_type, request.user, workflow)()) for node_type in ACTION_TYPES.iterkeys()] })
def edit_workflow_fork(request, action): fork = action LinkFormSet = modelformset_factory(Link, form=LinkForm, max_num=0) if request.method == 'POST': link_formset = LinkFormSet(request.POST) default_link_form = DefaultLinkForm(request.POST, action=fork) if link_formset.is_valid(): is_decision = fork.has_decisions() link_formset.save() if not is_decision and fork.has_decisions(): default_link = default_link_form.save(commit=False) default_link.parent = fork default_link.name = 'default' default_link.comment = 'default' default_link.save() fork.convert_to_decision() fork.update_description() return redirect( reverse('oozie:edit_workflow', kwargs={'workflow': fork.workflow.id})) else: if filter( lambda link: link.child.id != action.workflow.end.id, [link for link in fork.get_child_join().get_children_links()]): raise PopupException( _('Sorry, this Fork has some other actions below its Join and cannot be converted. ' 'Please delete the nodes below the Join.')) link_formset = LinkFormSet(queryset=fork.get_children_links()) default_link = Link(parent=fork, name='default', comment='default') default_link_form = DefaultLinkForm(action=fork, instance=default_link) return render( 'editor/edit_workflow_fork.mako', request, { 'workflow': fork.workflow, 'fork': fork, 'link_formset': link_formset, 'default_link_form': default_link_form, })
def edit_workflow_fork(request, action): fork = action LinkFormSet = modelformset_factory(Link, form=LinkForm, max_num=0) if request.method == 'POST': link_formset = LinkFormSet(request.POST) default_link_form = DefaultLinkForm(request.POST, action=fork) if link_formset.is_valid(): is_decision = fork.has_decisions() link_formset.save() if not is_decision and fork.has_decisions(): default_link = default_link_form.save(commit=False) default_link.parent = fork default_link.name = 'default' default_link.comment = 'default' default_link.save() fork.convert_to_decision() fork.update_description() return redirect(reverse('oozie:edit_workflow', kwargs={'workflow': fork.workflow.id})) else: if filter(lambda link: link.child.id != action.workflow.end.id, [link for link in fork.get_child_join().get_children_links()]): raise PopupException(_('Sorry, this Fork has some other actions below its Join and cannot be converted. ' 'Please delete the nodes below the Join.')) link_formset = LinkFormSet(queryset=fork.get_children_links()) default_link = Link(parent=fork, name='default', comment='default') default_link_form = DefaultLinkForm(action=fork, instance=default_link) return render('editor/edit_workflow_fork.mako', request, { 'workflow': fork.workflow, 'fork': fork, 'link_formset': link_formset, 'default_link_form': default_link_form, })
def edit_workflow(request, workflow): history = History.objects.filter(submitter=request.user, job=workflow).order_by('-submission_date') workflow_form = WorkflowForm(instance=workflow) user_can_access_job = workflow.can_read(request.user) user_can_edit_job = workflow.is_editable(request.user) oozie_api = get_oozie(request.user) credentials = Credentials() credentials.fetch(oozie_api) return render( 'editor/edit_workflow.mako', request, { 'oozie_api': oozie_api, 'workflow_form': workflow_form, 'workflow': workflow, 'history': history, 'user_can_access_job': user_can_access_job, 'user_can_edit_job': user_can_edit_job, 'job_properties': extract_field_data(workflow_form['job_properties']), 'link_form': LinkForm(), 'default_link_form': DefaultLinkForm(action=workflow.start), 'node_form': NodeForm(), 'action_forms': [(node_type, design_form_by_type(node_type, request.user, workflow)()) for node_type in ACTION_TYPES.keys()], 'credentials': json.dumps(list(credentials.credentials.keys())) })