@home.route('/open_eml_document', methods=['GET', 'POST'])
@login_required
def open_eml_document():
    form = OpenEMLDocumentForm()
    form.filename.choices = list_data_packages(False, False)
    if (request.method == 'POST'):
        if (BTN_CANCEL in request.form):
            return redirect(get_back_url())
        if form.validate_on_submit():
            filename = form.filename.data
            eml_node = load_eml(filename)
            if eml_node:
                current_user.set_filename(filename)
                packageid = eml_node.attributes.get('packageId', None)
                if packageid:
                    current_user.set_packageid(packageid)
                create_eml(filename=filename)
                new_page = PAGE_TITLE
            else:
                new_page = PAGE_FILE_ERROR
            return redirect(url_for(new_page, filename=filename))
    return render_template('open_eml_document.html', title='Open EML Document', form=form)
@home.route('/open_eml_document', methods=['GET', 'POST'])
@login_required
def open_eml_document():
    form = OpenEMLDocumentForm()
    form.filename.choices = list_data_packages(False, False)
    if (request.method == 'POST'):
        if (BTN_CANCEL in request.form):
            return redirect(get_back_url())
        if form.validate_on_submit():
            filename = form.filename.data
            eml_node = load_eml(filename)
            if eml_node:
                current_user.set_filename(filename)
                packageid = eml_node.attributes.get('packageId', None)
                if packageid:
                    current_user.set_packageid(packageid)
                create_eml(filename=filename)
                new_page = PAGE_TITLE
            else:
                new_page = PAGE_FILE_ERROR
            return redirect(url_for(new_page, filename=filename))
    return render_template('open_eml_document.html', title='Open EML Document', form=form)