def addSale(request): database = DB() if request.method == 'GET': customers = database.getUsers() departments = database.getDepartments() products = database.getProducts() return render(request,'addSale.html', {'customers':customers, 'departments':departments, 'products':products}) elif request.method == 'POST': database.saveSale(request.POST['userId'],request.POST['productId'],request.POST['departmentId'], request.POST['saleType'],request.POST['saleDescription']) return redirect(reverse('index') + '?message=Added Sale')
def editSale(request, id): database = DB() if request.method == 'GET': customers = database.getUsers() departments = database.getDepartments() products = database.getProducts() sale = database.getSale(id) print sale return render(request,'editSale.html', {'customers':customers, 'departments':departments, 'products':products, 'sale': sale }) else: database.updateSale(id, request.POST['userId'],request.POST['productId'],request.POST['departmentId'], request.POST['saleType'],request.POST['saleDescription']) return redirect(reverse('index') + '?message=Changed Sale')