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('/')
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('/')