Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
Hunger Buster - Breadcrumbs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Julia Santos
Hunger Buster - Breadcrumbs
Commits
41400cd4
Commit
41400cd4
authored
Mar 16, 2021
by
Julia Santos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added different sorting views for Product Type, added option to delete items
parent
4af4656a
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
114 additions
and
13 deletions
+114
-13
add-product-type.html
Breadcrumbs/templates/add-product-type.html
+41
-1
placeholder-list.html
Breadcrumbs/templates/placeholder-list.html
+11
-3
product-type-confirm-delete
Breadcrumbs/templates/product-type-confirm-delete
+4
-0
product-type-confirm-delete.html
Breadcrumbs/templates/product-type-confirm-delete.html
+8
-0
login.html
Breadcrumbs/templates/registration/login.html
+7
-1
urls.py
Breadcrumbs/urls.py
+6
-3
views.py
Breadcrumbs/views.py
+36
-4
settings.py
HungerBuster/settings.py
+1
-1
No files found.
Breadcrumbs/templates/add-product-type.html
View file @
41400cd4
<!DOCTYPE html>
<!DOCTYPE html>
<html
lang=
"en"
>
<html
lang=
"en"
>
{% load static %}
<link
rel=
"stylesheet"
href=
"{%static "
sidebar
.
css
"
%}"
>
<head>
<head>
<meta
charset=
"UTF-8"
>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Add Product Type
</title>
<title>
Add Product Type
</title>
</head>
</head>
<body>
<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>
<h3>
Add Product Type
</h3>
<form
method=
"POST"
enctype=
"multipart/form-data"
>
<form
method=
"POST"
enctype=
"multipart/form-data"
div
class=
"main"
>
{% csrf_token %}
{% csrf_token %}
{{ form.as_p }}
{{ form.as_p }}
<input
type=
"submit"
value=
"Submit"
>
<input
type=
"submit"
value=
"Submit"
>
</form>
</form>
<a
href=
"http://127.0.0.1:8000/fridge/list"
div
class=
"main"
>
Back
</a>
</body>
</body>
</html>
</html>
\ No newline at end of file
Breadcrumbs/templates/placeholder-list.html
View file @
41400cd4
...
@@ -46,8 +46,16 @@
...
@@ -46,8 +46,16 @@
</div>
</div>
</div>
</div>
<h2>
Fridge
</h2>
<h2>
Fridge
</h2>
<table
style=
"width:70%"
div
class=
"main"
>
<table
style=
"width:70%"
div
class=
"main"
>
<tr><th></th><th>
name
</th><th>
category
</th><th>
description
</th><th>
to buy?
</th><th>
user
</th></tr>
<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 %}
{% for product in object_list %}
<tr>
<tr>
<th>
<th>
...
@@ -66,7 +74,7 @@
...
@@ -66,7 +74,7 @@
{{product.To_Buy}}
{{product.To_Buy}}
</th>
</th>
<th>
<th>
{{product.User_ID.username}}
<a
href=
'http://127.0.0.1:8000/fridge/{{product.Product_ID}}/delete'
>
Delete?
</a>
</th>
</th>
</tr>
</tr>
{% endfor %}
{% endfor %}
...
...
Breadcrumbs/templates/product-type-confirm-delete
0 → 100644
View file @
41400cd4
<form method="post">{% csrf_token %}
<p>Are you sure you want to delete "{{ object }}"?</p>
<input type="submit" value="Confirm">
</form>
Breadcrumbs/templates/product-type-confirm-delete.html
0 → 100644
View file @
41400cd4
<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>
Breadcrumbs/templates/registration/login.html
View file @
41400cd4
<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"
>
<form
method=
"post"
>
{% csrf_token %}
{% csrf_token %}
{{ form.as_p }}
{{ form.as_p }}
...
...
Breadcrumbs/urls.py
View file @
41400cd4
...
@@ -4,13 +4,16 @@ from django.conf.urls.static import static
...
@@ -4,13 +4,16 @@ from django.conf.urls.static import static
from
django.views.generic
import
TemplateView
from
django.views.generic
import
TemplateView
from
django.urls
import
include
,
path
from
django.urls
import
include
,
path
from
Breadcrumbs
import
views
from
Breadcrumbs
import
views
from
.views
import
ProductListView
,
add_product_type
from
.views
import
ProductListView
Name
,
ProductListViewCategory
,
add_product_type
,
delete_product_type
#ProductTypeDeleteView
urlpatterns
=
[
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
(
'accounts/'
,
include
(
'django.contrib.auth.urls'
)),
#url('', ProductListView.as_view(), name='home'),
#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
:
if
settings
.
DEBUG
:
...
...
Breadcrumbs/views.py
View file @
41400cd4
from
django.views.generic
import
ListView
from
django.views.generic
import
ListView
from
.models
import
User
,
Product_Type
,
Item
,
Recipe
from
django.db.models
import
Q
from
django.db.models
import
Q
from
.forms
import
LoginForm
,
ProductTypeForm
from
.forms
import
LoginForm
,
ProductTypeForm
from
django.http
import
HttpResponseRedirect
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):
#class UserListView(ListView):
# model = User
# model = User
...
@@ -12,7 +15,7 @@ from django.shortcuts import render
...
@@ -12,7 +15,7 @@ from django.shortcuts import render
# def get_queryset(self):
# def get_queryset(self):
# return User.objects.all().order_by('User_ID')
# return User.objects.all().order_by('User_ID')
#User = settings.AUTH_USER_MODEL
#User = settings.AUTH_USER_MODEL
class
ProductListView
(
ListView
):
class
ProductListView
Name
(
ListView
):
model
=
Product_Type
model
=
Product_Type
template_name
=
'placeholder-list.html'
template_name
=
'placeholder-list.html'
context_object_name
=
'product'
context_object_name
=
'product'
...
@@ -20,6 +23,15 @@ class ProductListView(ListView):
...
@@ -20,6 +23,15 @@ class ProductListView(ListView):
def
get_queryset
(
self
):
def
get_queryset
(
self
):
return
Product_Type
.
objects
.
filter
(
User_ID
=
self
.
request
.
user
)
.
order_by
(
'Product_Name'
)
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
):
def
login
(
request
):
username
=
"not logged in"
username
=
"not logged in"
...
@@ -28,7 +40,7 @@ def login(request):
...
@@ -28,7 +40,7 @@ def login(request):
if
MyLoginForm
.
is_valid
():
if
MyLoginForm
.
is_valid
():
username
=
MyLoginForm
.
cleaned_data
[
'username'
]
username
=
MyLoginForm
.
cleaned_data
[
'username'
]
return
HttpResponseRedirect
(
'/fridge/list'
)
#
return HttpResponseRedirect('/fridge/list')
else
:
else
:
MyLoginForm
=
Loginform
()
MyLoginForm
=
Loginform
()
...
@@ -54,3 +66,23 @@ def add_product_type(request):
...
@@ -54,3 +66,23 @@ def add_product_type(request):
context
[
'form'
]
=
form
context
[
'form'
]
=
form
return
render
(
request
,
'add-product-type.html'
,
context
)
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
HungerBuster/settings.py
View file @
41400cd4
...
@@ -130,4 +130,4 @@ MEDIA_URL = '/media/'
...
@@ -130,4 +130,4 @@ MEDIA_URL = '/media/'
MEDIA_ROOT
=
os
.
path
.
join
(
BASE_DIR
,
'media'
)
MEDIA_ROOT
=
os
.
path
.
join
(
BASE_DIR
,
'media'
)
#for login
#for login
#LOGIN_REDIRECT_uRL = '
/'
LOGIN_REDIRECT_URL
=
'/fridge/list
/'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment