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
99bca4d0
Commit
99bca4d0
authored
Nov 23, 2016
by
Willard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add type and cuisine in dish forms
parent
0ed4f85d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
2 deletions
+10
-2
dish_views.py
canteeneo/dish_views.py
+3
-1
forms.py
canteeneo/forms.py
+1
-0
dishinfo.html
canteeneo/templates/dishinfo.html
+6
-1
No files found.
canteeneo/dish_views.py
View file @
99bca4d0
import
os.path
from
canteeneo
import
app
,
db
from
canteeneo.models
import
Stall
,
Dish
,
DishType
from
canteeneo.models
import
Stall
,
Dish
,
DishType
,
DishCuisine
from
canteeneo.forms
import
DishRegisterForm
from
canteeneo.views
import
flash_form_errors
,
stall_validate
,
dish_validate
,
FormView
...
...
@@ -28,6 +28,7 @@ class NewDishView(FormView):
def
get_form
(
self
):
form
=
DishRegisterForm
()
form
.
dish_type
.
choices
=
[(
dish_type
.
id
,
dish_type
.
name
)
for
dish_type
in
DishType
.
query
.
all
()]
form
.
dish_cuisine
.
choices
=
[(
dish_cuisine
.
id
,
dish_cuisine
.
name
)
for
dish_cuisine
in
DishCuisine
.
query
.
all
()]
return
form
class
DishView
(
View
):
...
...
@@ -62,6 +63,7 @@ class EditDishView(FormView):
def
get_form
(
self
):
form
=
DishRegisterForm
()
form
.
dish_type
.
choices
=
[(
dish_type
.
id
,
dish_type
.
name
)
for
dish_type
in
DishType
.
query
.
all
()]
form
.
dish_cuisine
.
choices
=
[(
dish_cuisine
.
id
,
dish_cuisine
.
name
)
for
dish_cuisine
in
DishCuisine
.
query
.
all
()]
form
.
editing
=
True
return
form
...
...
canteeneo/forms.py
View file @
99bca4d0
...
...
@@ -69,6 +69,7 @@ class DishRegisterForm(FlaskForm):
image
=
FileField
(
'Image'
)
price
=
DecimalField
(
'Price'
,
[
DataRequired
()],
render_kw
=
{
"placeholder"
:
"Price"
})
dish_type
=
SelectField
(
'Type'
,
coerce
=
int
)
dish_cuisine
=
SelectField
(
'Cuisine'
,
coerce
=
int
)
editing
=
False
def
validate
(
self
,
editing
=
False
):
...
...
canteeneo/templates/dishinfo.html
View file @
99bca4d0
...
...
@@ -26,7 +26,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
class=
"col-sm-6"
>
{{ form.dish_type.label(class_="col-sm-6 control-label") }} {{ form.dish_type(class_="form-control") }}
</div>
<div
class=
"col-sm-6"
>
{{ form.dish_cuisine.label(class_="col-sm-6 control-label") }} {{ form.dish_cuisine(class_="form-control") }}
</div>
</div>
<div
class=
"form-group form-group-lg"
>
<div
class=
"col-sm-6"
>
...
...
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