@home.route('/submit_package', methods=['GET', 'POST'])
@login_required
def submit_package():
    form = SubmitToEDIForm()
    if ((request.method == 'POST') and (BTN_CANCEL in request.form)):
        return redirect(get_back_url())
    (current_document, eml_node) = reload_metadata()
    if form.validate_on_submit():
        if (request.form.get(BTN_SUBMIT) == BTN_SUBMIT_TO_EDI):
            name = form.data['name']
            email_address = form.data['email_address']
            notes = form.data['notes']
            insert_upload_urls(current_document, eml_node)
            save_both_formats(filename=current_document, eml_node=eml_node)
            zipfile_path = zip_package(current_document, eml_node)
            if zipfile_path:
                (_, download_url) = save_as_ezeml_package_export(zipfile_path)
                msg = submit_package_mail_body(name, email_address, current_document, download_url, notes)
                subject = 'ezEML-Generated Data Submission Request'
                to_address = ['example@example.com']
                sent = mailout.send_mail(subject=subject, msg=msg, to=to_address)
                if sent:
                    flash(f'Package {current_document} has been sent to EDI. We will notify you when it has been added to the repository.')
                else:
                    flash(f'Email failed to send', 'error')
            return redirect(get_back_url())
    set_current_page('submit_package')
    help = get_helps(['submit_package'])
    return render_template('submit_package.html', title='Send to EDI', check_metadata_status=get_check_metadata_status(eml_node, current_document), form=form, help=help)
@home.route('/submit_package', methods=['GET', 'POST'])
@login_required
def submit_package():
    form = SubmitToEDIForm()
    if ((request.method == 'POST') and (BTN_CANCEL in request.form)):
        return redirect(get_back_url())
    (current_document, eml_node) = reload_metadata()
    if form.validate_on_submit():
        if (request.form.get(BTN_SUBMIT) == BTN_SUBMIT_TO_EDI):
            name = form.data['name']
            email_address = form.data['email_address']
            notes = form.data['notes']
            insert_upload_urls(current_document, eml_node)
            save_both_formats(filename=current_document, eml_node=eml_node)
            zipfile_path = zip_package(current_document, eml_node)
            if zipfile_path:
                (_, download_url) = save_as_ezeml_package_export(zipfile_path)
                msg = submit_package_mail_body(name, email_address, current_document, download_url, notes)
                subject = 'ezEML-Generated Data Submission Request'
                to_address = ['example@example.com']
                sent = mailout.send_mail(subject=subject, msg=msg, to=to_address)
                if sent:
                    flash(f'Package {current_document} has been sent to EDI. We will notify you when it has been added to the repository.')
                else:
                    flash(f'Email failed to send', 'error')
            return redirect(get_back_url())
    set_current_page('submit_package')
    help = get_helps(['submit_package'])
    return render_template('submit_package.html', title='Send to EDI', check_metadata_status=get_check_metadata_status(eml_node, current_document), form=form, help=help)