Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
thegoodplace
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Kirby Ezekiel Santos
thegoodplace
Commits
2df08a55
Commit
2df08a55
authored
Mar 18, 2020
by
Kirby Ezekiel Santos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the ingredients list page which uses an empty Ingredients model
parent
fe6632c2
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
93 additions
and
12 deletions
+93
-12
0001_initial.py
froyo/migrations/0001_initial.py
+22
-0
models.py
froyo/models.py
+9
-0
urls.py
froyo/urls.py
+4
-3
views.py
froyo/views.py
+19
-5
home_page.html
templates/home_page.html
+4
-4
ingredients_list.html
templates/ingredients_list.html
+35
-0
No files found.
froyo/migrations/0001_initial.py
0 → 100644
View file @
2df08a55
# Generated by Django 3.0.4 on 2020-03-18 08:12
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
initial
=
True
dependencies
=
[
]
operations
=
[
migrations
.
CreateModel
(
name
=
'Ingredient'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'name'
,
models
.
CharField
(
max_length
=
40
)),
(
'quantity'
,
models
.
CharField
(
max_length
=
40
)),
],
),
]
froyo/models.py
View file @
2df08a55
from
django.db
import
models
from
django.db
import
models
# Create your models here.
# Create your models here.
class
Ingredient
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
40
)
quantity
=
models
.
CharField
(
max_length
=
40
)
def
__str__
(
self
):
return
self
.
name
def
__str__
(
self
):
return
self
.
quantity
froyo/urls.py
View file @
2df08a55
from
django.contrib
import
admin
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
go_to_home_page
from
.views
import
HomePageView
from
.views
import
IngredientsListView
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
go_to_home_page
),
path
(
''
,
HomePageView
.
as_view
()),
path
(
'ingredients-list'
,
IngredientsListView
.
as_view
())
]
]
froyo/views.py
View file @
2df08a55
from
django.shortcuts
import
render
from
django.views.generic.base
import
TemplateView
from
django.views.generic.list
import
ListView
# Create your views here.
from
.models
import
Ingredient
home_page
=
"home_page.html"
def
go_to_home_page
(
request
):
class
HomePageView
(
TemplateView
):
return
render
(
request
,
home_page
)
template_name
=
"home_page.html"
class
IngredientsListView
(
ListView
):
template_name
=
"ingredients_list.html"
emptyIngredient
=
Ingredient
(
name
=
""
,
quantity
=
""
)
emptyIngredient
.
save
()
queryset
=
Ingredient
.
objects
.
all
()
context
=
{
"object_list"
:
queryset
}
templates/home_page.html
View file @
2df08a55
...
@@ -11,22 +11,22 @@
...
@@ -11,22 +11,22 @@
<div>
<div>
<h2
id=
"home_page_ingredients"
>
Ingredients
</h2>
<h2
id=
"home_page_ingredients"
>
Ingredients
</h2>
<form>
<form
method=
"get"
action=
"http://localhost:8000/ingredients-list"
>
<button
type=
"
button
"
id=
"button_to_ingredients"
>
View available ingredients
</button>
<button
type=
"
submit
"
id=
"button_to_ingredients"
>
View available ingredients
</button>
</form>
</form>
</div>
</div>
<div>
<div>
<h2
id=
"home_page_recipes"
>
Recipes
</h2>
<h2
id=
"home_page_recipes"
>
Recipes
</h2>
<form>
<form>
<button
type=
"
button
"
id=
"button_to_recipes"
>
Go to recipes
</button>
<button
type=
"
submit
"
id=
"button_to_recipes"
>
Go to recipes
</button>
</form>
</form>
</div>
</div>
<div>
<div>
<h2
id=
"home_page_orders"
>
Orders
</h2>
<h2
id=
"home_page_orders"
>
Orders
</h2>
<form>
<form>
<button
type=
"
button
"
id=
"button_to_orders"
>
Check current orders
</button>
<button
type=
"
submit
"
id=
"button_to_orders"
>
Check current orders
</button>
</form>
</form>
</div>
</div>
</body>
</body>
...
...
templates/ingredients_list.html
0 → 100644
View file @
2df08a55
<!DOCTYPE html>
<html>
<head>
<title>
Ingredients - List
</title>
</head>
<body>
<div>
<h1
id=
"page_header"
>
Ingredients - List
</h1>
</div>
<div>
<table
class=
"table"
>
<thead>
<tr>
<th>
Ingredient
</th>
<th></th>
</tr>
</thead>
<tbody>
{% for object in object_list %}
<tr>
<td>
{{object.name}}
</td>
<td>
<form>
<button
type=
"submit"
>
Go to detail
</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</body>
</html>
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