Exemplo n.º 1
0
def organization_delete_existing_position_process_form_view(
        request, organization_id, position_id):
    """

    :param request:
    :param organization_id:
    :param position_id:
    :return:
    """
    # If person isn't signed in, we don't want to let them visit this page yet
    if not request.user.is_authenticated():
        return redirect('/admin')

    organization_id = convert_to_int(organization_id)
    position_id = convert_to_int(position_id)

    # Get the existing position
    organization_position_on_stage_found = False
    if position_id > 0:
        organization_position_on_stage = PositionEntered()
        organization_position_on_stage_found = False
        position_entered_manager = PositionEnteredManager()
        results = position_entered_manager.retrieve_position_from_id(
            position_id)
        if results['position_found']:
            organization_position_on_stage_found = True
            organization_position_on_stage = results['position']

    if not organization_position_on_stage_found:
        messages.add_message(
            request, messages.INFO,
            "Could not find this organization's position when trying to delete."
        )
        return HttpResponseRedirect(
            reverse('organization:organization_position_list',
                    args=([organization_id])))

    try:
        organization_position_on_stage.delete()
    except Exception as e:
        handle_record_not_deleted_exception(e)
        messages.add_message(request, messages.ERROR,
                             'Could not delete position.')
        return HttpResponseRedirect(
            reverse('organization:organization_position_list',
                    args=([organization_id])))

    messages.add_message(request, messages.INFO, 'Position deleted.')
    return HttpResponseRedirect(
        reverse('organization:organization_position_list',
                args=([organization_id])))
Exemplo n.º 2
0
def organization_delete_existing_position_process_form_view(
        request, organization_id, position_we_vote_id):
    """

    :param request:
    :param organization_id:
    :param position_we_vote_id:
    :return:
    """
    authority_required = {'admin'}  # admin, verified_volunteer
    if not voter_has_authority(request, authority_required):
        return redirect_to_sign_in_page(request, authority_required)

    organization_id = convert_to_int(organization_id)

    # Get the existing position
    organization_position_on_stage_found = False
    if positive_value_exists(position_we_vote_id):
        organization_position_on_stage = PositionEntered()
        organization_position_on_stage_found = False
        position_entered_manager = PositionEnteredManager()
        results = position_entered_manager.retrieve_position_from_we_vote_id(
            position_we_vote_id)
        if results['position_found']:
            organization_position_on_stage_found = True
            organization_position_on_stage = results['position']

    if not organization_position_on_stage_found:
        messages.add_message(
            request, messages.INFO,
            "Could not find this organization's position when trying to delete."
        )
        return HttpResponseRedirect(
            reverse('organization:organization_position_list',
                    args=([organization_id])))

    try:
        organization_position_on_stage.delete()
    except Exception as e:
        handle_record_not_deleted_exception(e, logger=logger)
        messages.add_message(request, messages.ERROR,
                             'Could not delete position.')
        return HttpResponseRedirect(
            reverse('organization:organization_position_list',
                    args=([organization_id])))

    messages.add_message(request, messages.INFO, 'Position deleted.')
    return HttpResponseRedirect(
        reverse('organization:organization_position_edit',
                args=([organization_id])))
Exemplo n.º 3
0
def organization_delete_existing_position_process_form_view(request, organization_id, position_id):
    """

    :param request:
    :param organization_id:
    :param position_id:
    :return:
    """
    authority_required = {'admin'}  # admin, verified_volunteer
    if not voter_has_authority(request, authority_required):
        return redirect_to_sign_in_page(request, authority_required)

    organization_id = convert_to_int(organization_id)
    position_id = convert_to_int(position_id)

    # Get the existing position
    organization_position_on_stage_found = False
    if position_id > 0:
        organization_position_on_stage = PositionEntered()
        organization_position_on_stage_found = False
        position_entered_manager = PositionEnteredManager()
        results = position_entered_manager.retrieve_position_from_id(position_id)
        if results['position_found']:
            organization_position_on_stage_found = True
            organization_position_on_stage = results['position']

    if not organization_position_on_stage_found:
        messages.add_message(request, messages.INFO,
                             "Could not find this organization's position when trying to delete.")
        return HttpResponseRedirect(reverse('organization:organization_position_list', args=([organization_id])))

    try:
        organization_position_on_stage.delete()
    except Exception as e:
        handle_record_not_deleted_exception(e, logger=logger)
        messages.add_message(request, messages.ERROR,
                             'Could not delete position.')
        return HttpResponseRedirect(reverse('organization:organization_position_list', args=([organization_id])))

    messages.add_message(request, messages.INFO,
                         'Position deleted.')
    return HttpResponseRedirect(reverse('organization:organization_position_edit', args=([organization_id])))
Exemplo n.º 4
0
def organization_delete_existing_position_process_form_view(request, organization_id, position_id):
    """

    :param request:
    :param organization_id:
    :param position_id:
    :return:
    """
    # If person isn't signed in, we don't want to let them visit this page yet
    if not request.user.is_authenticated():
        return redirect('/admin')

    organization_id = convert_to_int(organization_id)
    position_id = convert_to_int(position_id)

    # Get the existing position
    organization_position_on_stage_found = False
    if position_id > 0:
        organization_position_on_stage = PositionEntered()
        organization_position_on_stage_found = False
        position_entered_manager = PositionEnteredManager()
        results = position_entered_manager.retrieve_position_from_id(position_id)
        if results['position_found']:
            organization_position_on_stage_found = True
            organization_position_on_stage = results['position']

    if not organization_position_on_stage_found:
        messages.add_message(request, messages.INFO,
                             "Could not find this organization's position when trying to delete.")
        return HttpResponseRedirect(reverse('organization:organization_position_list', args=([organization_id])))

    try:
        organization_position_on_stage.delete()
    except Exception as e:
        handle_record_not_deleted_exception(e)
        messages.add_message(request, messages.ERROR,
                             'Could not delete position.')
        return HttpResponseRedirect(reverse('organization:organization_position_list', args=([organization_id])))

    messages.add_message(request, messages.INFO,
                         'Position deleted.')
    return HttpResponseRedirect(reverse('organization:organization_position_list', args=([organization_id])))