Ejemplo n.º 1
0
def position_mapping(request):
    (render_value, error_message,
     context) = verify_access_logged_user_and_create_context(
         request, TAB_STRING)
    if context is None:
        request.session[ERROR_MESSAGE_KEY] = f'{error_message}<br>'
        return render_value
    context[ERROR_MESSAGES_KEY] = []

    return render(request, 'about/position_mapping/position_mapping.html',
                  update_context(context))
def update_saved_position_mappings(request):
    (render_value, error_message,
     context) = verify_access_logged_user_and_create_context(
         request, TAB_STRING)
    if context is None:
        request.session[ERROR_MESSAGE_KEY] = f'{error_message}<br>'
        return render_value

    if request.method == "POST":
        context[ERROR_MESSAGES_KEY] = _update_positions_mapping(
            list(
                parser.parse(request.POST.urlencode())
                ['saved_officer_positions'].values()))
    return render(request, 'about/position_mapping/position_mapping.html',
                  update_context(context))
def update_saved_position_mappings(request):
    (render_value, error_message,
     context) = verify_access_logged_user_and_create_context(
         request, TAB_STRING)
    if context is None:
        request.session[ERROR_MESSAGE_KEY] = f'{error_message}<br>'
        return render_value

    if request.method == "POST":
        post_dict = parser.parse(request.POST.urlencode())
        if DELETE_POSITION_MAPPING_KEY in post_dict or UN_DELETED_POSITION_MAPPING_KEY in post_dict:
            success, error_message = _delete_or_undelete_position_mapping(
                post_dict)
            if not success:
                context[ERROR_MESSAGES_KEY] = [f"{error_message}"]
        elif UPDATE_POSITION_MAPPING_KEY in post_dict:
            context[ERROR_MESSAGES_KEY] = _update_position_mapping(post_dict)
    return render(request, 'about/position_mapping/position_mapping.html',
                  update_context(context))
Ejemplo n.º 4
0
def input_new_officer_positions(request):
    logger.info(
        "[about/input_new_officer_positions.py input_new_officer_positions()]"
        f" request.POST={request.POST}")
    (render_value, error_message,
     context) = verify_access_logged_user_and_create_context(
         request, TAB_STRING)
    if context is None:
        request.session[ERROR_MESSAGE_KEY] = f'{error_message}<br>'
        return render_value
    context[ERROR_MESSAGES_KEY] = []
    if request.method == "POST":
        post_dict = parser.parse(request.POST.urlencode())
        if 'add_new_position_mapping' in post_dict:
            success, context[ERROR_MESSAGES_KEY], context[UNSAVED_POSITION_MAPPINGS_KEY] = \
                _add_new_position_mapping(post_dict)

    return render(request, 'about/position_mapping/position_mapping.html',
                  update_context(context))
Ejemplo n.º 5
0
def update_saved_github_mappings(request):
    logger.info(
        "[about/update_saved_github_mappings.py update_saved_github_mappings()]"
        f" request.POST={request.POST}")
    (render_value, error_message,
     context) = verify_access_logged_user_and_create_context(
         request, TAB_STRING)
    if render_value is not None:
        request.session[ERROR_MESSAGE_KEY] = f'{error_message}<br>'
        return render_value
    context[ERROR_MESSAGES_KEY] = []
    if request.method == "POST":
        github_mappings = list(
            parser.parse(request.POST.urlencode())
            ['saved_officer_position_github_mapping'].values())
        for github_mapping in github_mappings:
            context[ERROR_MESSAGES_KEY].extend(
                _update_github_mapping(github_mapping))
    return render(request, 'about/position_mapping/position_mapping.html',
                  update_context(context))
def save_new_github_officer_team_mapping(request):
    logger.info(
        f"[about/save_new_github_officer_team_mapping.py save_new_github_officer_team_mapping()] "
        f"request.POST={request.POST}")
    (render_value, error_message,
     context) = verify_access_logged_user_and_create_context(
         request, TAB_STRING)
    if context is None:
        request.session[ERROR_MESSAGE_KEY] = f'{error_message}<br>'
        return render_value
    context[ERROR_MESSAGES_KEY] = []

    if request.method == "POST":
        post_dict = parser.parse(request.POST.urlencode())
        if 'create_new_github_mapping' in post_dict:
            context[UNSAVED_GITHUB_OFFICER_TEAM_NAME_MAPPINGS_KEY], \
                context[ERROR_MESSAGES_KEY] = _create_new_github_mapping(post_dict)
            if context[UNSAVED_GITHUB_OFFICER_TEAM_NAME_MAPPINGS_KEY] is None:
                del context[UNSAVED_GITHUB_OFFICER_TEAM_NAME_MAPPINGS_KEY]

    return render(request, 'about/position_mapping/position_mapping.html',
                  update_context(context))
def update_saved_github_mappings(request):
    logger.info(
        "[about/update_saved_github_mappings.py update_saved_github_mappings()]"
        f" request.POST={request.POST}"
    )
    (render_value, error_message, context) = verify_access_logged_user_and_create_context(request,
                                                                                          TAB_STRING)
    if context is None:
        request.session[ERROR_MESSAGE_KEY] = f'{error_message}<br>'
        return render_value
    context[ERROR_MESSAGES_KEY] = []
    if request.method == "POST":
        post_dict = parser.parse(request.POST.urlencode())
        if "un_delete_github_mapping" in post_dict:
            context[ERROR_MESSAGES_KEY] = _toggle_deletion_status_for_github_mapping(post_dict, False)
        elif "mark_for_deletion_github_mapping" in post_dict:
            context[ERROR_MESSAGES_KEY] = _toggle_deletion_status_for_github_mapping(post_dict, True)
        elif "update_github_mapping" in post_dict:
            context[ERROR_MESSAGES_KEY] = _update_github_mapping(post_dict)
        elif "delete_github_mapping" in post_dict:
            context[ERROR_MESSAGES_KEY] = _delete_github_mapping(post_dict)

    return render(request, 'about/position_mapping/position_mapping.html', update_context(context))