Ejemplo n.º 1
0
def handbag_edit_workflow(wf_id):
    url = scads_url + 'workflow?id=' + wf_id
    wf = requests.get(url).json()
    wf['maxBagSize'] = int(wf['maxBagSize'] / 1000000000)
    form = HandbagWorkflowForm(**wf)
    if form.addMetadata.data:
        form.metadata.append_entry()
    elif form.delMetadata.data:
        if form.metadata.data:
            form.metadata.pop_entry()
        else:
            flash('No metadata fields to delete')
    elif request.form and form.validate():
        metadata = []
        while form.metadata.data:
            m = form.metadata.pop_entry().data
            if m['presetValue'] == '':
                m.pop('presetValue')
            metadata.insert(0, m)
        results = form.data
        profile = process_results(results, metadata)
        post_to_scads(profile, scads_url + 'workflows')
        flash('Profile "%s" updated' % (form.name.data))
        return redirect('/')
    return render_template('handbag.html', form=form, status="Edit")
Ejemplo n.º 2
0
def handbag():
    form = HandbagWorkflowForm()
    if form.addMetadata.data:
        form.metadata.append_entry()
    elif form.delMetadata.data:
        if form.metadata.data:
            form.metadata.pop_entry()
        else:
            flash('No metadata fields to delete')
    elif request.form and form.validate():
        metadata = []
        while form.metadata.data:
            m = form.metadata.pop_entry().data
            if m['presetValue'] == '':
                m.pop('presetValue')
            metadata.insert(0, m)
        results = form.data
        profile = process_results(results, metadata)
        post_to_scads(profile, scads_url + 'workflows?agent=anon')
        flash('Profile "%s" created' % (form.name.data))
        return redirect('/')
    return render_template('handbag.html', form=form, status="New")