Commit 11ef102e authored by Julia Santos's avatar Julia Santos

Merge branch 'Login' into 'master'

Login

See merge request !3
parents d09485d4 41400cd4
body {
width: 100%;
height: 100%;
margin: 0px;
}
.listViewHeader {
background-color: rgba(40, 40, 40, 1);
width: 100vw;
color: white;
text-align: left;
}
.breadcrumbsHead {
font-family: "Roboto Bold";
font-size: 46px;
margin-left: 50px;
}
.lowerPage {
width: 100vw;
display: grid;
grid-template-columns: repeat(6, 16.67vw);
text-align: left;
}
.sidebar {
background-color: rgba(196, 196, 196, 1);
display: grid;
grid-template-rows: repeat(16, 6.25vh);
grid-column: 1/2;
}
.sideItem {
grid-template-columns: repeat(2, 12.5vw);
text-align: center;
background-color: rgba(104, 104, 104, 1);
}
.text {
font-family: "Roboto";
font-size: 24px;
color: white;
grid-column: 2/3;
}
.icon {
grid-column: 1/2;
}
.circle {
margin: 5px;
clip-path: circle();
background-color: white;
}
.fridge {
grid-row: 3/4;
}
.recipes {
grid-row: 6/7;
}
.stats {
grid-row: 9/10;
}
.toBuy {
grid-row: 12/13;
}
@font-face {
font-family: Roboto Bold;
src: url(Roboto-Bold.ttf);
}
@font-face {
font-family: Roboto;
src: url(Roboto-Regular.ttf);
}
\ No newline at end of file
body {
width: 100%;
height: 100%;
margin: 0px;
}
.listViewHeader {
background-color: rgba(40, 40, 40, 1);
width: 100vw;
color: white;
text-align: left;
}
.breadcrumbsHead {
font-family: "Roboto Bold";
font-size: 46px;
margin-left: 50px;
}
.lowerPage {
width: 100vw;
display: grid;
grid-template-columns: repeat(6, 16.67vw);
text-align: left;
}
.sidebar {
height: 100%;
position:fixed;
width:265px;
background-color: rgba(196, 196, 196, 1);
display: grid;
grid-template-rows: repeat(16, 6.25vh);
grid-column: 1/2;
z-index:1;
left:0;
}
.sideItem {
grid-template-columns: repeat(2, 12.5vw);
text-align: center;
background-color: rgba(104, 104, 104, 1);
}
.text {
font-family: "Roboto";
font-size: 24px;
color: white;
grid-column: 2/3;
}
.icon {
grid-column: 1/2;
}
.circle {
margin: 5px;
clip-path: circle();
background-color: white;
}
.fridge {
grid-row: 3/4;
}
.recipes {
grid-row: 6/7;
}
.stats {
grid-row: 9/10;
}
.toBuy {
grid-row: 12/13;
}
@font-face {
font-family: Roboto Bold;
src: url(Roboto-Bold.ttf);
}
@font-face {
font-family: Roboto;
src: url(Roboto-Regular.ttf);
}
.main{
margin-left:23%;
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
{% load static %}
<link rel="stylesheet" href="{%static "sidebar.css" %}">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add Product Type</title>
</head>
<body>
<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>
<h3>Add Product Type</h3>
<form method="POST" enctype="multipart/form-data">
<form method="POST" enctype="multipart/form-data" div class="main">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit">
</form>
<a href="http://127.0.0.1:8000/fridge/list" div class="main">Back</a>
</body>
</html>
\ No newline at end of file
<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:100%">
<tr><th></th><th>name</th><th>category</th><th>description</th><th>to buy?</th><th>user</th></tr>
<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/list/">name</a></th>
<th><a href="http://127.0.0.1:8000/fridge/list-category">category</a></th>
<th>description</th>
<th>to buy?</th>
<th>user</th>
</tr>
{% for product in object_list %}
<tr>
<th>
......@@ -28,7 +74,7 @@
{{product.To_Buy}}
</th>
<th>
{{product.User_ID.username}}
<a href='http://127.0.0.1:8000/fridge/{{product.Product_ID}}/delete'>Delete?</a>
</th>
</tr>
{% endfor %}
......
<form method="post">{% csrf_token %}
<p>Are you sure you want to delete "{{ object }}"?</p>
<input type="submit" value="Confirm">
</form>
<html>
<body>
<form method="post">{% csrf_token %}
<p>Are you sure you want to delete "{{ object }}"?</p>
<input type="submit" value="Confirm">
</form>
</body>
</html>
<h2>Log In</h2>
{% load static %}
<link rel="stylesheet" href="{%static "sidebar.css" %}">
<div class = "listViewHeader">
<div class = "breadcrumbsHead">
BREADCRUMBS
</div>
</div>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
......
......@@ -4,13 +4,16 @@ 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 ProductListView, add_product_type
from .views import ProductListViewName, ProductListViewCategory, add_product_type, delete_product_type #ProductTypeDeleteView
urlpatterns = [
url(r'^fridge/list/', ProductListView.as_view(), name='fridgeL'),
url(r'^fridge/list/', ProductListViewName.as_view(), name='fridgeLN'),
url(r'^fridge/list-category', ProductListViewCategory.as_view(), name='fridgeLC'),
url('accounts/', include('django.contrib.auth.urls')),
#url('', ProductListView.as_view(), name='home'),
path('fridge/add/', add_product_type, name = 'product-type-form')
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'),
]
if settings.DEBUG:
......
from django.views.generic import ListView
from .models import User, Product_Type, Item, Recipe
from django.db.models import Q
from .forms import LoginForm, ProductTypeForm
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.shortcuts import render, get_object_or_404
from django.views.generic.edit import DeleteView
from .models import User, Product_Type, Item, Recipe
#class UserListView(ListView):
# model = User
......@@ -12,7 +15,7 @@ from django.shortcuts import render
# def get_queryset(self):
# return User.objects.all().order_by('User_ID')
#User = settings.AUTH_USER_MODEL
class ProductListView(ListView):
class ProductListViewName(ListView):
model = Product_Type
template_name = 'placeholder-list.html'
context_object_name = 'product'
......@@ -20,6 +23,15 @@ class ProductListView(ListView):
def get_queryset(self):
return Product_Type.objects.filter(User_ID=self.request.user).order_by('Product_Name')
class ProductListViewCategory(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).order_by('Product_Category')
def login(request):
username = "not logged in"
......@@ -28,7 +40,7 @@ def login(request):
if MyLoginForm.is_valid():
username = MyLoginForm.cleaned_data['username']
return HttpResponseRedirect('/fridge/list')
#return HttpResponseRedirect('/fridge/list')
else:
MyLoginForm = Loginform()
......@@ -54,3 +66,23 @@ def add_product_type(request):
context['form'] = form
return render(request,'add-product-type.html',context)
def delete_product_type(request,id):
context = {}
obj = get_object_or_404(Product_Type,Product_ID = id)
if request.method=="POST":
obj.delete()
return HttpResponseRedirect("/fridge/list/")
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/'
# 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
......@@ -23,10 +23,16 @@ body {
text-align: left;
}
.sidebar {
height: 100%;
position:fixed;
width:265px;
background-color: rgba(196, 196, 196, 1);
display: grid;
grid-template-rows: repeat(16, 6.25vh);
grid-column: 1/2;
z-index:1;
left:0;
}
.sideItem {
grid-template-columns: repeat(2, 12.5vw);
......@@ -68,3 +74,7 @@ body {
font-family: Roboto;
src: url(Roboto-Regular.ttf);
}
.main{
margin-left:23%;
}
\ No newline at end of file
......@@ -130,4 +130,4 @@ MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
#for login
#LOGIN_REDIRECT_uRL = '/'
LOGIN_REDIRECT_URL = '/fridge/list/'
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