Exemplo n.º 1
0
def srp_request_update_amount_view(request, fleet_srp_request_id):
    logger.debug("srp_request_update_amount_view called by user %s for fleet srp request id %s" % (request.user, fleet_srp_request_id))
    no_srp_code = False
    srp_code = ""

    if SrpUserRequest.objects.filter(id=fleet_srp_request_id).exists() is False:
        logger.error("Unable to locate SRP request id %s for user %s" % (fleet_srp_request_id, request.user))
        no_srp_code = True

    if request.method == 'POST':
        form = SrpFleetUpdateCostForm(request.POST)
        logger.debug("Request type POST contains form valid: %s" % form.is_valid())
        if form.is_valid():
            srp_request = SrpUserRequest.objects.get(id=fleet_srp_request_id)
            srp_request.srp_total_amount = form.cleaned_data['srp_total_amount']
            srp_request.save()
            logger.info("Updated srp request id %s total to %s by user %s" % (fleet_srp_request_id, form.cleaned_data['srp_total_amount'], request.user))

            return HttpResponseRedirect("/srp_fleet_view/" + str(srp_request.srp_fleet_main.id))
    else:
        logger.debug("Returning blank SrpFleetUpdateCostForm")
        form = SrpFleetUpdateCostForm()

    render_items = {'form': form, "no_srp_code": no_srp_code}

    return render_to_response('registered/srpfleetrequestamount.html', render_items,
                              context_instance=RequestContext(request))
Exemplo n.º 2
0
def srp_request_update_amount_view(request, fleet_srp_request_id):
    no_srp_code = False
    srp_code = ""

    if SrpUserRequest.objects.filter(id=fleet_srp_request_id).exists() is False:
        no_srp_code = True

    if request.method == 'POST':
        form = SrpFleetUpdateCostForm(request.POST)

        if form.is_valid():
            srp_request = SrpUserRequest.objects.get(id=fleet_srp_request_id)
            srp_request.srp_total_amount = form.cleaned_data['srp_total_amount']
            srp_request.save()

            return HttpResponseRedirect("/srp_fleet_view/" + str(srp_request.srp_fleet_main.id))
    else:
        form = SrpFleetUpdateCostForm()

    render_items = {'form': form, "no_srp_code": no_srp_code}

    return render_to_response('registered/srpfleetrequestamount.html', render_items,
                              context_instance=RequestContext(request))