Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CS123-Canteeneo
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Willard Torres
CS123-Canteeneo
Commits
7cb53f8a
Commit
7cb53f8a
authored
Nov 17, 2016
by
Willard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Style dish info, make edit and new dish use the same template
parent
c46a32aa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
84 deletions
+55
-84
dish_views.py
canteeneo/dish_views.py
+4
-2
dishinfo.html
canteeneo/templates/dishinfo.html
+51
-0
editdish.html
canteeneo/templates/editdish.html
+0
-41
newdish.html
canteeneo/templates/newdish.html
+0
-41
No files found.
canteeneo/dish_views.py
View file @
7cb53f8a
...
...
@@ -24,7 +24,7 @@ class NewDishView(FormView):
db
.
session
.
commit
()
return
redirect
(
url_for
(
'view_stall'
,
stall_id
=
self
.
stall
.
id
))
def
render_get
(
self
,
stall_id
):
return
render_template
(
'
newdish.html'
,
form
=
self
.
get_form
(),
stall
=
self
.
stall
)
return
render_template
(
'
dishinfo.html'
,
form
=
self
.
get_form
(),
stall
=
self
.
stall
,
title
=
'New Dish'
,
form_action
=
url_for
(
'stalls'
,
stall_id
=
stall_id
),
submit_label
=
'Add'
)
def
get_form
(
self
):
form
=
DishRegisterForm
()
form
.
dish_type
.
choices
=
[(
dish_type
.
id
,
dish_type
.
name
)
for
dish_type
in
DishType
.
query
.
all
()]
...
...
@@ -56,7 +56,9 @@ class EditDishView(FormView):
form
.
name
.
data
=
self
.
dish
.
name
form
.
description
.
data
=
self
.
dish
.
description
form
.
price
.
data
=
self
.
dish
.
price
return
render_template
(
'editdish.html'
,
form
=
form
,
stall
=
self
.
stall
,
dish
=
self
.
dish
)
return
render_template
(
'dishinfo.html'
,
form
=
form
,
stall
=
self
.
stall
,
dish
=
self
.
dish
,
title
=
'Edit Info'
,
form_action
=
url_for
(
'edit_dish'
,
stall_id
=
self
.
stall
.
id
,
dish_id
=
self
.
dish
.
id
),
image_preview
=
url_for
(
'static'
,
filename
=
'uploads/'
+
self
.
dish
.
image_path
),
submit_label
=
'Edit'
)
def
get_form
(
self
):
form
=
DishRegisterForm
()
form
.
dish_type
.
choices
=
[(
dish_type
.
id
,
dish_type
.
name
)
for
dish_type
in
DishType
.
query
.
all
()]
...
...
canteeneo/templates/dishinfo.html
0 → 100644
View file @
7cb53f8a
{% extends "base.html" %}
{% block title %}{{ title }}{% endblock %}
{% block content %}
<div
class=
"row"
>
<div
class=
"col-md-6 col-md-offset-3"
>
<h1>
Dish Info
</h1>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-6 col-md-offset-3"
>
<form
action=
"{{ form_action }}"
enctype=
"multipart/form-data"
method=
"POST"
>
{{ form.csrf_token }}
<div
class=
"form-group form-group-lg col-sm-8"
>
{{ form.name(class_="form-control") }}
</div>
<div
class=
"form-group form-group-lg col-sm-12"
>
<span
style=
"display: flex;"
>
<img
id=
"image-preview"
src=
"{{ image_preview }}"
width=
"160px"
height=
"160px"
>
{{ form.image(id="image-upload") }}
</span>
</div>
<div
class=
"form-group form-group-lg col-sm-12"
>
{{ form.description(class_="form-control", rows=16) }}
</div>
<div
class=
"form-group form-group-lg col-sm-12"
>
{{ form.price(class_="form-control", type="number") }}
</div>
<div
class=
"form-group form-group-lg col-sm-12"
>
{{ form.dish_type.label(class_="col-sm-6 control-label") }} {{ form.dish_type(class_="form-control") }}
</div>
<div
class=
"form-group form-group-lg"
>
<div
class=
"col-sm-6"
>
<button
class=
"btn btn-primary btn-block btn-lg"
type=
"submit"
>
{{ submit_label }}
</button>
</div>
<div
class=
"col-sm-6"
>
<a
class=
"btn btn-default btn-block btn-lg"
href=
"{{ url_for('view_stall', stall_id=stall.id) }}"
>
Back
</a>
</div>
</div>
</form>
</div>
</div>
<script>
document
.
getElementById
(
"image-upload"
).
onchange
=
function
()
{
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
e
)
{
document
.
getElementById
(
"image-preview"
).
src
=
e
.
target
.
result
;
};
reader
.
readAsDataURL
(
this
.
files
[
0
])
}
</script>
{% endblock %}
\ No newline at end of file
canteeneo/templates/editdish.html
deleted
100644 → 0
View file @
c46a32aa
{% extends "base.html" %} {% block title %}Edit Dish Info{% endblock %} {% block content %}
<h1>
Dish Info
</h1>
<div
id=
"form"
>
<form
action=
"{{ url_for('edit_dish', stall_id=stall.id, dish_id=dish.id) }}"
enctype=
"multipart/form-data"
method=
"POST"
>
{{ form.csrf_token }}
<div
class=
"form-input"
>
<div
class=
"input-row"
>
{{ form.name.label(class_="field-label") }} {{ form.name(class_="text-field") }}
</div>
<div
class=
"input-row"
>
<span
style=
"display: flex;"
>
<img
id=
"image-preview"
src=
"{{url_for('static', filename='uploads/'+dish.image_path)}}"
width=
"160px"
height=
"160px"
>
{{ form.image(id="image-upload") }}
</span>
</div>
<div
class=
"input-row"
>
{{ form.description.label(class_="field-label") }} {{ form.description(class_="text-area", rows=6, cols=32) }}
</div>
<div
class=
"input-row"
>
{{ form.price.label(class_="field-label") }} {{ form.price(class_="text-field", type="number", style="width: 5em;") }}
</div>
<div
class=
"input-row"
>
{{ form.dish_type.label(class_="field-label") }} {{ form.dish_type(class_="text-field") }}
</div>
</div>
<div
class=
"dashboard-row"
>
<button
type=
"submit"
>
Apply
</button>
<a
href=
"{{ url_for('view_stall', stall_id=stall.id) }}"
><button
type=
"button"
class=
"link-button"
>
Back
</button></a>
</div>
</form>
</div>
<script>
document
.
getElementById
(
"image-upload"
).
onchange
=
function
()
{
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
e
)
{
document
.
getElementById
(
"image-preview"
).
src
=
e
.
target
.
result
;
};
reader
.
readAsDataURL
(
this
.
files
[
0
])
}
</script>
{% endblock %}
\ No newline at end of file
canteeneo/templates/newdish.html
deleted
100644 → 0
View file @
c46a32aa
{% extends "base.html" %} {% block title %}Add Food Item{% endblock %} {% block content %}
<h1>
Dish Info
</h1>
<form
action=
"{{ url_for('new_dish', stall_id=stall.id) }}"
enctype=
"multipart/form-data"
method=
"POST"
>
{{ form.csrf_token }}
<div
id=
"form"
>
<div
class=
"form-input"
>
<div
class=
"input-row"
>
{{ form.name.label(class_="field-label") }} {{ form.name(class_="text-field") }}
</div>
<div
class=
"input-row"
>
<span
style=
"display: flex;"
>
<img
id=
"image-preview"
width=
"160px"
height=
"160px"
>
{{ form.image(id="image-upload") }}
</span>
</div>
<div
class=
"input-row"
>
{{ form.description.label(class_="field-label") }} {{ form.description(class_="text-area", rows=6, cols=32) }}
</div>
<div
class=
"input-row"
>
{{ form.price.label(class_="field-label") }} {{ form.price(class_="text-field", type="number", style="width: 5em;") }}
</div>
<div
class=
"input-row"
>
{{ form.dish_type.label(class_="field-label") }} {{ form.dish_type(class_="text-field") }}
</div>
</div>
<div
class=
"dashboard-row"
>
<button
type=
"submit"
>
Add
</button>
<a
href=
"{{ url_for('stalls', stall_id=stall.id) }}"
><button
type=
"button"
class=
"link-button"
>
Back
</button></a>
</div>
</div>
</form>
<script>
document
.
getElementById
(
"image-upload"
).
onchange
=
function
()
{
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
e
)
{
document
.
getElementById
(
"image-preview"
).
src
=
e
.
target
.
result
;
};
reader
.
readAsDataURL
(
this
.
files
[
0
])
}
</script>
{% endblock %}
\ No newline at end of file
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