Skip to content
Snippets Groups Projects
Commit 79b3e4f1 authored by Lukas Schneider's avatar Lukas Schneider
Browse files

Update views to pass data with the new data model to the buy template

parent 6844642f
No related branches found
No related tags found
No related merge requests found
from django.shortcuts import render, reverse
from .models import User, Product, UserIdentifierTypes
from .models import User, Product, UserIdentifierTypes, ProductIdentifierTypes
from django.views.decorators.http import require_http_methods
from django.views.decorators.csrf import csrf_protect
from django.contrib.auth.decorators import login_required
......@@ -35,9 +35,10 @@ def buy(request):
return render(request, "buy.html", {
"most_bought": ProductLogic.getMostBoughtProductsList(),
"recently_bought": ProductLogic.getLastBoughtProductsList(request.user.id),
"drinks": Product.objects.filter(category="drink").order_by('name'),
"candies": Product.objects.filter(category="candy").order_by('name'),
"drinks": ProductLogic.getDrinks(),
"candies": ProductLogic.getCandies(),
"products": Product.objects.all(),
"ident_types": ProductIdentifierTypes.to_dict(),
})
elif request.method == 'POST': # Perform a purchase
user_id = request.user.id
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment