def enter_request(request):

    name = request.POST['name']

    try:
        customer = creditapprovalclient.getCustomerByName(name)
        customer = ratingclient.setRating(customer)
        sessionstore.set_customer(request, customer)

    except Exception as e:
        messages.error(request, e)
        return HttpResponseRedirect(request.META['HTTP_REFERER'])

    return render_to_response('enter-request.html', {
            'customer': customer,
            'target': 'create-request',
        }, context_instance=RequestContext(request))
def show_warrantor(request):
    name = request.POST['name']

    credit_req = sessionstore.get_request(request)

    try:
        warrantor = creditapprovalclient.getCustomerByName(name)
    except:
        messages.error(request, 'Customer with name "{name}" not found'.format(
            name=name))
        warrantor = None

    if warrantor:
        warrantor = ratingclient.setRating(warrantor)
        credit_req.warrantors.append(warrantor)

    sessionstore.set_request(request, credit_req)

    return render_to_response('search-warrantors.html', {
            'credit_request': credit_req,
        }, context_instance=RequestContext(request))