def index(request): """ Shows the home page """ request_context = RequestContext(request, { 'categories': get_categories(request), }) return render(request, "home.html", request_context)
def showcategory(request, category): """ Shows a page with all products related to a category """ # Get the category object cat = Category.objects.get(name=category) # Get all products belonging to taht category products = Asset.objects.filter(category=cat) request_context = RequestContext(request, { 'categories': get_categories(request, current=category), 'category': cat, 'products': products, }) return render(request, "category.html", request_context)
def showproduct(request, productID): """ Show a page with information about a specific product """ # Get asset asset = Asset.objects.get(pk=productID) # Get grade. rating = get_rating(productID) request_context = RequestContext(request, { 'categories': get_categories(request), 'asset': asset, 'rating': rating, }) return render(request, "product.html", request_context)