@home.route('/load_other_entity/<node_id>', methods=['GET', 'POST'])
@login_required
def load_entity(node_id=None):
    form = LoadOtherEntityForm()
    document = current_user.get_filename()
    uploads_folder = user_data.get_document_uploads_folder_name()
    if ((request.method == 'POST') and (BTN_CANCEL in request.form)):
        return redirect(get_back_url())
    if ((request.method == 'POST') and form.validate_on_submit()):
        if ('file' not in request.files):
            flash('No file part', 'error')
            return redirect(request.url)
        file = request.files['file']
        if file:
            filename = file.filename
            if ((filename is None) or (filename == '')):
                flash('No selected file', 'error')
            else:
                file.save(os.path.join(uploads_folder, filename))
                data_file = filename
                data_file_path = f'{uploads_folder}/{data_file}'
                flash(f'Loaded {data_file}')
                eml_node = load_eml(filename=document)
                dataset_node = eml_node.find_child(names.DATASET)
                other_entity_node = load_other_entity(dataset_node, uploads_folder, data_file, node_id=node_id)
                save_both_formats(filename=document, eml_node=eml_node)
                return redirect(url_for(PAGE_OTHER_ENTITY, filename=document, node_id=other_entity_node.id))
    return render_template('load_other_entity.html', title='Load Other Entity', form=form)
@home.route('/load_other_entity/<node_id>', methods=['GET', 'POST'])
@login_required
def load_entity(node_id=None):
    form = LoadOtherEntityForm()
    document = current_user.get_filename()
    uploads_folder = user_data.get_document_uploads_folder_name()
    if ((request.method == 'POST') and (BTN_CANCEL in request.form)):
        return redirect(get_back_url())
    if ((request.method == 'POST') and form.validate_on_submit()):
        if ('file' not in request.files):
            flash('No file part', 'error')
            return redirect(request.url)
        file = request.files['file']
        if file:
            filename = file.filename
            if ((filename is None) or (filename == )):
                flash('No selected file', 'error')
            else:
                file.save(os.path.join(uploads_folder, filename))
                data_file = filename
                data_file_path = f'{uploads_folder}/{data_file}'
                flash(f'Loaded {data_file}')
                eml_node = load_eml(filename=document)
                dataset_node = eml_node.find_child(names.DATASET)
                other_entity_node = load_other_entity(dataset_node, uploads_folder, data_file, node_id=node_id)
                save_both_formats(filename=document, eml_node=eml_node)
                return redirect(url_for(PAGE_OTHER_ENTITY, filename=document, node_id=other_entity_node.id))
    return render_template('load_other_entity.html', title='Load Other Entity', form=form)