@home.route('/import_parties_2/<filename>/', methods=['GET', 'POST'])
@login_required
def import_parties_2(filename):
    form = ImportEMLItemsForm()
    eml_node = load_eml(filename)
    parties = get_responsible_parties_for_import(eml_node)
    choices = [[party[2], party[1]] for party in parties]
    form.to_import.choices = choices
    targets = [('Creators', 'Creators'), ('Metadata Providers', 'Metadata Providers'), ('Associated Parties', 'Associated Parties'), ('Contacts', 'Contacts'), ('Publisher', 'Publisher'), ('Project Personnel', 'Project Personnel')]
    form.target.choices = targets
    if ((request.method == 'POST') and (BTN_CANCEL in request.form)):
        return redirect(get_back_url())
    if form.validate_on_submit():
        node_ids_to_import = form.data['to_import']
        target_class = form.data['target']
        target_filename = current_user.get_filename()
        import_responsible_parties(target_filename, node_ids_to_import, target_class)
        if (target_class == 'Creators'):
            new_page = PAGE_CREATOR_SELECT
        elif (target_class == 'Metadata Providers'):
            new_page = PAGE_METADATA_PROVIDER_SELECT
        elif (target_class == 'Associated Parties'):
            new_page = PAGE_ASSOCIATED_PARTY_SELECT
        elif (target_class == 'Contacts'):
            new_page = PAGE_CONTACT_SELECT
        elif (target_class == 'Publisher'):
            new_page = PAGE_PUBLISHER
        elif (target_class == 'Project Personnel'):
            new_page = PAGE_PROJECT_PERSONNEL_SELECT
        return redirect(url_for(new_page, filename=target_filename))
    help = get_helps(['import_responsible_parties_2'])
    return render_template('import_parties_2.html', target_filename=filename, help=help, form=form)
@home.route('/import_parties_2/<filename>/', methods=['GET', 'POST'])
@login_required
def import_parties_2(filename):
    form = ImportEMLItemsForm()
    eml_node = load_eml(filename)
    parties = get_responsible_parties_for_import(eml_node)
    choices = [[party[2], party[1]] for party in parties]
    form.to_import.choices = choices
    targets = [('Creators', 'Creators'), ('Metadata Providers', 'Metadata Providers'), ('Associated Parties', 'Associated Parties'), ('Contacts', 'Contacts'), ('Publisher', 'Publisher'), ('Project Personnel', 'Project Personnel')]
    form.target.choices = targets
    if ((request.method == 'POST') and (BTN_CANCEL in request.form)):
        return redirect(get_back_url())
    if form.validate_on_submit():
        node_ids_to_import = form.data['to_import']
        target_class = form.data['target']
        target_filename = current_user.get_filename()
        import_responsible_parties(target_filename, node_ids_to_import, target_class)
        if (target_class == 'Creators'):
            new_page = PAGE_CREATOR_SELECT
        elif (target_class == 'Metadata Providers'):
            new_page = PAGE_METADATA_PROVIDER_SELECT
        elif (target_class == 'Associated Parties'):
            new_page = PAGE_ASSOCIATED_PARTY_SELECT
        elif (target_class == 'Contacts'):
            new_page = PAGE_CONTACT_SELECT
        elif (target_class == 'Publisher'):
            new_page = PAGE_PUBLISHER
        elif (target_class == 'Project Personnel'):
            new_page = PAGE_PROJECT_PERSONNEL_SELECT
        return redirect(url_for(new_page, filename=target_filename))
    help = get_helps(['import_responsible_parties_2'])
    return render_template('import_parties_2.html', target_filename=filename, help=help, form=form)