@home.route('/reupload_data/<filename>/<dt_node_id>', methods=['GET', 'POST'])
@home.route('/reupload_data/<filename>/<dt_node_id>/<saved_filename>/<name_chg_ok>', methods=['GET', 'POST'])
@login_required
def reupload_data(dt_node_id=None, filename=None, saved_filename=None, name_chg_ok=False):
    filename = None
    form = LoadDataForm()
    document = current_user.get_filename()
    uploads_folder = user_data.get_document_uploads_folder_name()
    eml_node = load_eml(filename=document)
    data_table_name = ''
    dt_node = Node.get_node_instance(dt_node_id)
    if dt_node:
        entity_name_node = dt_node.find_child(names.ENTITYNAME)
        if entity_name_node:
            data_table_name = entity_name_node.content
            if (not data_table_name):
                flash(f'Data table name not found in the metadata.', 'error')
                return redirect(request.url)
    if ((request.method == 'POST') and (BTN_CANCEL in request.form)):
        url = url_for(PAGE_DATA_TABLE_SELECT, filename=document)
        return redirect(url)
    if (request.method == 'POST'):
        if dt_node:
            if saved_filename:
                filename = saved_filename
            else:
                file = request.files['file']
                if file:
                    filename = f'{file.filename}'
                    if allowed_data_file(filename):
                        filename = f'{filename}.ezeml_tmp'
                        filepath = os.path.join(uploads_folder, filename)
                        file.save(filepath)
                    else:
                        flash(f'{filename} is not a supported data file type', 'error')
                        return redirect(request.url)
            delimiter = form.delimiter.data
            quote_char = form.quote.data
            try:
                return handle_reupload(dt_node_id=dt_node_id, saved_filename=filename, document=document, eml_node=eml_node, uploads_folder=uploads_folder, name_chg_ok=name_chg_ok, delimiter=delimiter, quote_char=quote_char)
            except MissingFileError as err:
                flash(err.message, 'error')
                return redirect(request.url)
            except Exception as err:
                return redirect(request.url)
    help = get_helps(['data_table_reupload_full'])
    return render_template('reupload_data.html', title='Re-upload Data Table', form=form, name=data_table_name, help=help)
@home.route('/reupload_data/<filename>/<dt_node_id>', methods=['GET', 'POST'])
@home.route('/reupload_data/<filename>/<dt_node_id>/<saved_filename>/<name_chg_ok>', methods=['GET', 'POST'])
@login_required
def reupload_data(dt_node_id=None, filename=None, saved_filename=None, name_chg_ok=False):
    filename = None
    form = LoadDataForm()
    document = current_user.get_filename()
    uploads_folder = user_data.get_document_uploads_folder_name()
    eml_node = load_eml(filename=document)
    data_table_name = 
    dt_node = Node.get_node_instance(dt_node_id)
    if dt_node:
        entity_name_node = dt_node.find_child(names.ENTITYNAME)
        if entity_name_node:
            data_table_name = entity_name_node.content
            if (not data_table_name):
                flash(f'Data table name not found in the metadata.', 'error')
                return redirect(request.url)
    if ((request.method == 'POST') and (BTN_CANCEL in request.form)):
        url = url_for(PAGE_DATA_TABLE_SELECT, filename=document)
        return redirect(url)
    if (request.method == 'POST'):
        if dt_node:
            if saved_filename:
                filename = saved_filename
            else:
                file = request.files['file']
                if file:
                    filename = f'{file.filename}'
                    if allowed_data_file(filename):
                        filename = f'{filename}.ezeml_tmp'
                        filepath = os.path.join(uploads_folder, filename)
                        file.save(filepath)
                    else:
                        flash(f'{filename} is not a supported data file type', 'error')
                        return redirect(request.url)
            delimiter = form.delimiter.data
            quote_char = form.quote.data
            try:
                return handle_reupload(dt_node_id=dt_node_id, saved_filename=filename, document=document, eml_node=eml_node, uploads_folder=uploads_folder, name_chg_ok=name_chg_ok, delimiter=delimiter, quote_char=quote_char)
            except MissingFileError as err:
                flash(err.message, 'error')
                return redirect(request.url)
            except Exception as err:
                return redirect(request.url)
    help = get_helps(['data_table_reupload_full'])
    return render_template('reupload_data.html', title='Re-upload Data Table', form=form, name=data_table_name, help=help)