Ejemplo n.º 1
0
def related_project_select_post(filename=None,
                                form=None,
                                form_dict=None,
                                method=None,
                                this_page=None,
                                back_page=None,
                                next_page=None,
                                edit_page=None):
    node_id = None
    new_page = None
    if form_dict:
        for key in form_dict:
            val = form_dict[key][0]  # value is the first list element
            if val == BTN_BACK:
                new_page = back_page
            elif val == BTN_NEXT or val == BTN_SAVE_AND_CONTINUE:
                new_page = next_page
            elif val == BTN_EDIT:
                new_page = edit_page
                node_id = key
            elif val == BTN_REMOVE:
                new_page = this_page
                node_id = key
                remove_related_project(filename, node_id)
            elif val == BTN_HIDDEN_CHECK:
                new_page = PAGE_CHECK
            elif val == BTN_HIDDEN_SAVE:
                new_page = this_page
            elif val == BTN_HIDDEN_DOWNLOAD:
                new_page = PAGE_DOWNLOAD
            elif val == BTN_HIDDEN_NEW:
                new_page = PAGE_CREATE
            elif val == BTN_HIDDEN_OPEN:
                new_page = PAGE_OPEN
            elif val == BTN_HIDDEN_CLOSE:
                new_page = PAGE_CLOSE
            elif val == UP_ARROW:
                new_page = this_page
                node_id = key
                process_up_button(filename, node_id)
            elif val == DOWN_ARROW:
                new_page = this_page
                node_id = key
                process_down_button(filename, node_id)
            elif val[0:3] == BTN_ADD:
                new_page = edit_page
                node_id = '1'
            elif val[0:4] == BTN_BACK:
                new_page = edit_page
                node_id = None

    if form.validate_on_submit():
        if new_page == edit_page:
            return url_for(new_page,
                           filename=filename,
                           node_id=node_id,
                           title='Related Project')
        else:
            return url_for(new_page, filename=filename)
Ejemplo n.º 2
0
def funding_award_select(filename=None, project_node_id=None):
    form = AwardSelectForm(filename=filename)

    # Process POST
    if request.method == 'POST':
        form_value = request.form
        form_dict = form_value.to_dict(flat=False)
        node_id = None

        new_page = PAGE_FUNDING_AWARD_SELECT
        if form_dict:
            for key in form_dict:
                val = form_dict[key][0]  # value is the first list element
                if val == BTN_SAVE_AND_CONTINUE:
                    new_page = PAGE_PROJECT
                elif val[0:4] == 'Back':
                    new_page = PAGE_PROJECT
                elif val == BTN_EDIT:
                    new_page = PAGE_FUNDING_AWARD
                    node_id = key
                elif val == BTN_REMOVE:
                    new_page = PAGE_FUNDING_AWARD_SELECT
                    node_id = key
                    eml_node = load_eml(filename=filename)
                    remove_child(node_id=node_id)
                    save_both_formats(filename=filename, eml_node=eml_node)
                elif val == UP_ARROW:
                    new_page = PAGE_FUNDING_AWARD_SELECT
                    node_id = key
                    process_up_button(filename, node_id)
                elif val == DOWN_ARROW:
                    new_page = PAGE_FUNDING_AWARD_SELECT
                    node_id = key
                    process_down_button(filename, node_id)
                elif val[0:3] == 'Add':
                    new_page = PAGE_FUNDING_AWARD
                    node_id = '1'
                else:
                    new_page = check_val_for_hidden_buttons(
                        val, new_page, PAGE_FUNDING_AWARD_SELECT)

        if form.validate_on_submit():
            if node_id and project_node_id:
                url = url_for(new_page,
                              filename=filename,
                              node_id=node_id,
                              project_node_id=project_node_id)
            elif project_node_id:
                url = url_for(new_page,
                              filename=filename,
                              project_node_id=project_node_id)
            else:
                url = url_for(new_page, filename=filename, node_id=node_id)
            return redirect(url)

    # Process GET
    return funding_award_select_get(filename=filename,
                                    form=form,
                                    project_node_id=project_node_id)
Ejemplo n.º 3
0
def related_project_select_post(filename=None,
                                form=None,
                                form_dict=None,
                                method=None,
                                this_page=None,
                                back_page=None,
                                next_page=None,
                                edit_page=None):
    project_node_id = None
    new_page = None
    if form_dict:
        for key in form_dict:
            val = form_dict[key][0]  # value is the first list element
            if val == BTN_BACK:
                new_page = back_page
            elif val == BTN_NEXT or val == BTN_SAVE_AND_CONTINUE:
                new_page = next_page
            elif val == BTN_EDIT:
                new_page = edit_page
                project_node_id = key
            elif val == BTN_REMOVE:
                new_page = this_page
                project_node_id = key
                remove_related_project(filename, project_node_id)
            elif val == UP_ARROW:
                new_page = this_page
                node_id = key
                process_up_button(filename, node_id)
            elif val == DOWN_ARROW:
                new_page = this_page
                node_id = key
                process_down_button(filename, node_id)
            elif val[0:3] == BTN_ADD:
                new_page = edit_page
                project_node_id = '1'
            elif val[0:4] == BTN_BACK:
                new_page = edit_page
                project_node_id = None
            else:
                new_page = check_val_for_hidden_buttons(
                    val, new_page, this_page)

    if form.validate_on_submit():
        if new_page == edit_page:
            return url_for(new_page,
                           filename=filename,
                           project_node_id=project_node_id,
                           title='Related Project')
        else:
            return url_for(new_page, filename=filename)
Ejemplo n.º 4
0
def access_select_post(filename=None,
                       form=None,
                       form_dict=None,
                       method=None,
                       this_page=None,
                       back_page=None,
                       next_page=None,
                       edit_page=None):
    node_id = ''
    new_page = ''
    if form_dict:
        for key in form_dict:
            val = form_dict[key][0]  # value is the first list element
            if val == 'Back':
                new_page = back_page
            elif val == 'Next':
                new_page = next_page
            elif val == 'Edit':
                new_page = edit_page
                node_id = key
            elif val == 'Remove':
                new_page = this_page
                node_id = key
                eml_node = load_eml(filename=filename)
                remove_child(node_id=node_id)
                save_both_formats(filename=filename, eml_node=eml_node)
            elif val == UP_ARROW:
                new_page = this_page
                node_id = key
                process_up_button(filename, node_id)
            elif val == DOWN_ARROW:
                new_page = this_page
                node_id = key
                process_down_button(filename, node_id)
            elif val[0:3] == 'Add':
                new_page = edit_page
                node_id = '1'

    if form.validate_on_submit():
        if new_page == edit_page:
            return url_for(new_page, filename=filename, node_id=node_id)
        elif new_page == this_page:
            return url_for(new_page, filename=filename, node_id=node_id)
        elif new_page == back_page or new_page == next_page:
            return url_for(new_page, filename=filename)
Ejemplo n.º 5
0
def method_step_select(filename=None):
    form = MethodStepSelectForm(filename=filename)

    # Process POST
    if request.method == 'POST':
        form_value = request.form
        form_dict = form_value.to_dict(flat=False)
        node_id = ''
        new_page = ''
        url = ''
        this_page = PAGE_METHOD_STEP_SELECT
        edit_page = PAGE_METHOD_STEP
        back_page = PAGE_PUBLICATION_INFO
        next_page = PAGE_PROJECT

        if form_dict:
            for key in form_dict:
                val = form_dict[key][0]  # value is the first list element
                if val == BTN_BACK:
                    new_page = back_page
                elif val in [BTN_NEXT, BTN_SAVE_AND_CONTINUE]:
                    new_page = next_page
                elif val == BTN_EDIT:
                    new_page = edit_page
                    node_id = key
                elif val == BTN_REMOVE:
                    new_page = this_page
                    node_id = key
                    eml_node = load_eml(filename=filename)
                    remove_child(node_id=node_id)
                    save_both_formats(filename=filename, eml_node=eml_node)
                elif val == BTN_HIDDEN_CHECK:
                    new_page = PAGE_CHECK
                elif val == BTN_HIDDEN_SAVE:
                    new_page = this_page
                elif val == BTN_HIDDEN_DOWNLOAD:
                    new_page = PAGE_DOWNLOAD
                elif val == BTN_HIDDEN_NEW:
                    new_page = PAGE_CREATE
                elif val == BTN_HIDDEN_OPEN:
                    new_page = PAGE_OPEN
                elif val == BTN_HIDDEN_CLOSE:
                    new_page = PAGE_CLOSE
                elif val == UP_ARROW:
                    new_page = this_page
                    node_id = key
                    process_up_button(filename, node_id)
                elif val == DOWN_ARROW:
                    new_page = this_page
                    node_id = key
                    process_down_button(filename, node_id)
                elif val[0:3] == 'Add':
                    new_page = edit_page
                    node_id = '1'
                elif val == '[  ]':
                    new_page = this_page
                    node_id = key

        if form.validate_on_submit():
            if new_page in [edit_page, this_page]:
                url = url_for(new_page, filename=filename, node_id=node_id)
            else:
                url = url_for(new_page, filename=filename)
            return redirect(url)

    # Process GET
    method_step_list = []
    title = 'Method Steps'
    eml_node = load_eml(filename=filename)

    if eml_node:
        dataset_node = eml_node.find_child(names.DATASET)
        if dataset_node:
            method_step_list = list_method_steps(dataset_node)

    set_current_page('method_step')
    help = [get_help('methods')]
    return render_template('method_step_select.html',
                           title=title,
                           filename=filename,
                           method_step_list=method_step_list,
                           form=form,
                           help=help)