Commit ad9dcc73 authored by Julia Santos's avatar Julia Santos

Individual items now display when clicking on Product

parent 66990953
<html>
<title>Fridge</title>
{% load static %}
<link rel="stylesheet" href="{%static "sidebar.css" %}">
{% block content %}
<style>
table, th, td {
border: 1px solid black;
}
</style>
<div class = "listViewHeader">
<div class = "breadcrumbsHead">
BREADCRUMBS
</div>
</div>
<div class = "lowerPage">
<div class = "sidebar">
<div class = "sideItem text fridge">
FRIDGE
</div>
<div class = "sideItem icon fridge">
<div class = "circle"> :3 </div>
</div>
<div class = "sideItem text recipes">
RECIPES
</div>
<div class = "sideItem icon recipes">
<div class = "circle"> :3 </div>
</div>
<div class = "sideItem text stats">
STATS
</div>
<div class = "sideItem icon stats">
<div class = "circle"> :3 </div>
</div>
<div class = "sideItem text toBuy">
TO BUY
</div>
<div class = "sideItem icon toBuy">
<div class = "circle"> :3 </div>
</div>
</div>
</div>
<h2>Fridge</h2>
<table style="width:70%" div class="main">
<tr><th colspan="5"><a href="http://127.0.0.1:8000/fridge/add/"> Add Item</a></th></tr>
<tr><th></th>
<th><a href="http://127.0.0.1:8000/fridge{{object_list.Product_ID}}">Name</a></th>
<th><a href="http://127.0.0.1:8000/fridge/{{object_list.Product_ID}}">Description</a></th>
<th>Quantity</th>
<th>Expiration Date</th>
<th>Purchase Date</th>
<th>Status</th>
</tr>
{% for item in object_list %}
<tr>
<th>
{{item.Product_ID.Product_Name}}
</th>
<th>
{{item.Item_Description}}
</th>
<th>
{{item.Item_Quantity}} {{item.Quantity_Unit}}
</th>
<th>
{{item.Expiration_Date}}
</th>
<th>
{{item.Purchase_Date}}
</th>
<th>
{{item.Is_Expired}}
</th>
<th>
<a href='http://127.0.0.1:8000/fridge/{{item.Item_ID}}/delete'>Delete?</a>
</th>
</tr>
{% endfor %}
</table>
{% endblock %}
</html>
......@@ -62,7 +62,8 @@
<img src = "{{product.Icon.url}}" width = "100" height ="100">
</th>
<th>
{{product.Product_Name}}
<a href='http://127.0.0.1:8000/fridge/{{product.Product_ID}}'>
{{product.Product_Name}}</a>
</th>
<th>
{{product.Product_Category}}
......
......@@ -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 #ProductTypeDeleteView
from .views import ProductListViewName, ProductListViewCategory, add_product_type, delete_product_type, ItemViewPDate#item_view_by_pdate
urlpatterns = [
url(r'^fridge/list/', ProductListViewName.as_view(), name='fridgeLN'),
......@@ -14,6 +14,7 @@ urlpatterns = [
path('fridge/add/', add_product_type, name = 'product-type-form'),
#path('fridge/<pk>/delete', ProductTypeDeleteView.as_view()),
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' )
]
if settings.DEBUG:
......
......@@ -2,7 +2,7 @@ from django.views.generic import ListView
from django.db.models import Q
from .forms import LoginForm, ProductTypeForm
from django.http import HttpResponseRedirect
from django.shortcuts import render, get_object_or_404
from django.shortcuts import render, get_object_or_404#, render_to_response
from django.forms import ValidationError
from django.views.generic.edit import DeleteView
......@@ -83,15 +83,21 @@ def delete_product_type(request,id):
obj.delete()
return HttpResponseRedirect("/fridge/list/")
return render(request, 'product-type-confirm-delete.html',context)
return render(request, 'product-type-confirm-delete.html', context)
# class ProductTypeDeleteView(DeleteView):
# models = Product_Type
# template_name = 'product-type-confirm-delete.html'
# success_url = 'fridge/list/'
class ItemViewPDate(ListView):
model = Item
template_name = 'placeholder-items.html'
context_object_name = 'item'
# def get_object(self, queryset=None):
# obj = super(ProductTypeDeleteView, self).get_object()
# if not obj.owner == self.request.user:
# raise Http404
# return obj
\ No newline at end of file
def get_queryset(self, **kwargs):
return Item.objects.filter(User_ID=self.request.user).order_by('Purchase_Date').filter(Product_ID=self.kwargs['Product_ID'])
#def get_queryset(self, **kwargs):
# return Item.objects.filter(User_ID=self.request.user).order_by('Purchase_Date').filter(Product_ID=)
# def get_context_data(self, **kwargs):
# return Item.objects.filter(User_ID=self.request.user).get(Product_ID=kwargs['Product_ID'])
#def item_view_by_pdate(request, Product_ID):
# items = Item.objects.filter(User_ID = self.request.user).filter(Product_ID= Product_ID)
# context = items
# return render(request,'placeholder-items.html',items)
\ No newline at end of file
......@@ -55,32 +55,32 @@ body {
}
#fridgeIcon {
background-color: white;
clip-path: circle();
height: 100px;
clip-path: circle();
height: 100px;
grid-row: 2/6;
grid-column: 1/2;
margin: 10px;
}
#recipesIcon {
background-color: white;
clip-path: circle();
height: 100px;
clip-path: circle();
height: 100px;
grid-row: 5/9;
grid-column: 1/2;
margin: 10px;
}
#statsIcon {
background-color: white;
clip-path: circle();
height: 100px;
clip-path: circle();
height: 100px;
grid-row: 8/12;
grid-column: 1/2;
margin: 10px;
}
#toBuyIcon {
background-color: white;
clip-path: circle();
height: 100px;
clip-path: circle();
height: 100px;
grid-row: 11/15;
grid-column: 1/2;
margin: 10px;
......@@ -113,4 +113,4 @@ body {
.main{
margin-left:23%;
}
\ No newline at end of file
}
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