@home.route('/delete', methods=['GET', 'POST'])
@login_required
def delete():
    form = DeleteEMLForm()
    form.filename.choices = list_data_packages(True, True)
    if (request.method == 'POST'):
        if ('Cancel' in request.form):
            return redirect(get_back_url())
        if form.validate_on_submit():
            filename = form.filename.data
            user_data.discard_data_table_upload_filenames_for_package(filename)
            return_value = user_data.delete_eml(filename=filename)
            if (filename == user_data.get_active_document()):
                current_user.set_filename(None)
            if isinstance(return_value, str):
                flash(return_value)
            else:
                flash(f'Deleted {filename}')
            return redirect(url_for(PAGE_INDEX))
    return render_template('delete_eml.html', title='Delete EML', form=form)
@home.route('/delete', methods=['GET', 'POST'])
@login_required
def delete():
    form = DeleteEMLForm()
    form.filename.choices = list_data_packages(True, True)
    if (request.method == 'POST'):
        if ('Cancel' in request.form):
            return redirect(get_back_url())
        if form.validate_on_submit():
            filename = form.filename.data
            user_data.discard_data_table_upload_filenames_for_package(filename)
            return_value = user_data.delete_eml(filename=filename)
            if (filename == user_data.get_active_document()):
                current_user.set_filename(None)
            if isinstance(return_value, str):
                flash(return_value)
            else:
                flash(f'Deleted {filename}')
            return redirect(url_for(PAGE_INDEX))
    return render_template('delete_eml.html', title='Delete EML', form=form)