Commit 393a2df7 authored by Julia Santos's avatar Julia Santos

Merge branch 'To-Buy' into 'master'

Users can now view all items marked as To Buy

See merge request !8
parents b7eb640e a514ed45
......@@ -4,7 +4,7 @@ from django.conf.urls.static import static
from django.views.generic import TemplateView
from django.urls import include, path
from Breadcrumbs import views
from .views import ProductListViewName, ProductListViewCategory, add_product_type, delete_product_type, ItemViewPDate, add_item, delete_item
from .views import ProductListViewName, ProductListViewCategory, add_product_type, delete_product_type, ItemViewPDate, add_item, delete_item, ToBuyViewName
urlpatterns = [
url(r'^fridge/list/', ProductListViewName.as_view(), name='fridgeLN'),
......@@ -14,7 +14,8 @@ urlpatterns = [
path('fridge/<id>/delete', delete_product_type, name='product-type-delete'),
url(r'^fridge/(?P<Product_ID>\d+)/$', ItemViewPDate.as_view(), name='item-purchase-date-view'),
path('fridge/<id>/add', add_item, name = 'add-item'),
path('fridge/<id>/<id2>/delete', delete_item, name = 'delete-item')
path('fridge/<id>/<id2>/delete', delete_item, name = 'delete-item'),
url(r'^to-buy/', ToBuyViewName.as_view(), name = 'to-buyLN')
]
if settings.DEBUG:
......
......@@ -40,7 +40,31 @@ class ProductListViewCategory(ListView):
def get_queryset(self):
return Product_Type.objects.filter(User_ID=self.request.user).order_by('Product_Category')
class ToBuyViewName(ListView):
model = Product_Type
template_name = 'placeholder-list.html'
context_object_name = 'product'
def get_queryset(self):
return Product_Type.objects.filter(User_ID=self.request.user).filter(To_Buy = True).order_by('Product_Name')
def login(request):
username = "not logged in"
if request.method =="POST":
MyLoginForm = LoginForm(request.POST)
if MyLoginForm.is_valid():
username = MyLoginForm.cleaned_data['username']
#return HttpResponseRedirect('/fridge/list')
else:
MyLoginForm = Loginform()
return render(request, loggedin.html,{"username" : username})
def add_product_type(request):
context = {}
if request.method == 'POST':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment