# Path: products/views.py
# def productIndexView(request):
# 
#     queryset = Product.objects.all()
#     context = {
#         "products": queryset,
#     }
# 
#     return render(request, "productIndex.html", context)
# 
# def productDetailView(request, product_id):
#     try:
#         product = Product.objects.get(pk=product_id)
#     except Product.DoesNotExist:
#         raise Http404("The product does not exist")
#     return render(request, "productDetail.html", {'product': product})
# 
# def categoryIndexView(request):
# 
#     queryset = ProductCategory.objects.all()
#     context = {
#         "categories": queryset,
#     }
# 
#     return render(request, "categoryIndex.html", context)
# 
# def categoryDetailView(request, category_id):
# 
#     category = ProductCategory.objects.get(pk=category_id)
#     queryset = Product.objects.filter(category_id=category_id)
#     context = {
#         "products": queryset,
#         "category": category,
#     }
# 
#     return render(request, "categoryDetail.html", context)
# 
# def addProductToCartView(request, product_id):
# 
#     quantity = request.POST['quantity']
#     CartManagement.addToCart(request, product_id, quantity)
# 
#     return redirect('/cart/cart_detail')
# 
# def productFilterView(request):
#     products = Product.objects.all()
#     var_get_search = request.GET.get('search_product')
#     if var_get_search is not None:
#         products = products.filter(product_name__contains=var_get_search)
# 
#     return render(request, 'productFilter.html', {'products': products})


from django.conf import settings
from django.conf.urls import url
from django.conf.urls.static import static
from django.contrib.auth.decorators import login_required
from products.views import (
    productIndexView,
    productDetailView,
    categoryIndexView,
    categoryDetailView,
    addProductToCartView,
    productFilterView,
    )

urlpatterns = [
    url(r'^index/', productIndexView, name='productIndexView'),
    url(r'^(?P<product_id>[0-9]+)/details/$', productDetailView,
        name='productDetailView'),
    url(r'^productFilter/', productFilterView, name='productFilterView'),

# Path: products/views.py
# def productIndexView(request):
# 
#     queryset = Product.objects.all()
#     context = {
#         "products": queryset,
#     }
# 
#     return render(request, "productIndex.html", context)
# 
# def productDetailView(request, product_id):
#     try:
#         product = Product.objects.get(pk=product_id)
#     except Product.DoesNotExist:
#         raise Http404("The product does not exist")
#     return render(request, "productDetail.html", {'product': product})
# 
# def categoryIndexView(request):
# 
#     queryset = ProductCategory.objects.all()
#     context = {
#         "categories": queryset,
#     }
# 
#     return render(request, "categoryIndex.html", context)
# 
# def categoryDetailView(request, category_id):
# 
#     category = ProductCategory.objects.get(pk=category_id)
#     queryset = Product.objects.filter(category_id=category_id)
#     context = {
#         "products": queryset,
#         "category": category,
#     }
# 
#     return render(request, "categoryDetail.html", context)
# 
# def addProductToCartView(request, product_id):
# 
#     quantity = request.POST['quantity']
#     CartManagement.addToCart(request, product_id, quantity)
# 
#     return redirect('/cart/cart_detail')
# 
# def productFilterView(request):
#     products = Product.objects.all()
#     var_get_search = request.GET.get('search_product')
#     if var_get_search is not None:
#         products = products.filter(product_name__contains=var_get_search)
# 
#     return render(request, 'productFilter.html', {'products': products})


# Path: products/urls.py
from django.conf import settings
from django.conf.urls import url
from django.conf.urls.static import static
from django.contrib.auth.decorators import login_required
from products.views import (
    productIndexView,
    productDetailView,
    categoryIndexView,
    categoryDetailView,
    addProductToCartView,
    productFilterView,
    )


urlpatterns = [
    url(r'^index/', productIndexView, name='productIndexView'),
    url(r'^(?P<product_id>[0-9]+)/details/$', productDetailView,
        name='productDetailView'),
    url(r'^productFilter/', productFilterView, name='productFilterView'),

    url(r'^list/', categoryIndexView, name='categoryIndexView'),