Exemplo n.º 1
0
def add(request):
    database = DB()
    if request.method == 'GET':
        address = database.getAddressList()
        car = database.getCarList()
        client = database.getClientList()
        return render(request, 'add_page.html', {
            'address': address,
            'car': car,
            'client': client
        })
    elif request.method == 'POST':
        database.saveOrder(request.POST['start_id'], request.POST['finish_id'],
                           request.POST['car_id'], request.POST['client_id'],
                           request.POST['entry-day-time'])
        return redirect('/')
Exemplo n.º 2
0
def edit(request, id):
    database = DB()
    if request.method == 'GET':
        address = database.getAddressList()
        car = database.getCarList()
        client = database.getClientList()
        order = database.getOrder(id)
        return render(request, 'edit_page.html', {
            'address': address,
            'car': car,
            'client': client,
            'order': order
        })
    else:
        database.updateOrder(id, request.POST['start_id'],
                             request.POST['finish_id'], request.POST['car_id'],
                             request.POST['client_id'],
                             request.POST['entry-day-time'])
        return redirect('/')