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
b58e050f
Commit
b58e050f
authored
Nov 09, 2016
by
Willard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Place editing field in form class
parent
fbc4c82f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
forms.py
canteeneo/forms.py
+2
-1
stall_views.py
canteeneo/stall_views.py
+2
-1
No files found.
canteeneo/forms.py
View file @
b58e050f
...
@@ -49,13 +49,14 @@ class StallRegisterForm(FlaskForm):
...
@@ -49,13 +49,14 @@ class StallRegisterForm(FlaskForm):
description
=
TextAreaField
(
'Description'
,
[
DataRequired
()])
description
=
TextAreaField
(
'Description'
,
[
DataRequired
()])
image
=
FileField
(
'Image'
)
image
=
FileField
(
'Image'
)
location
=
SelectField
(
coerce
=
int
)
location
=
SelectField
(
coerce
=
int
)
editing
=
False
def
validate
(
self
,
editing
=
False
):
def
validate
(
self
,
editing
=
False
):
if
not
FlaskForm
.
validate
(
self
):
if
not
FlaskForm
.
validate
(
self
):
return
False
return
False
stall
=
Stall
.
query
.
filter_by
(
name
=
self
.
name
.
data
)
.
first
()
stall
=
Stall
.
query
.
filter_by
(
name
=
self
.
name
.
data
)
.
first
()
if
not
editing
:
if
not
self
.
editing
:
if
stall
is
not
None
:
if
stall
is
not
None
:
flash
(
'Stall name is taken!'
)
flash
(
'Stall name is taken!'
)
return
False
return
False
...
...
canteeneo/stall_views.py
View file @
b58e050f
...
@@ -42,10 +42,11 @@ def new_stall():
...
@@ -42,10 +42,11 @@ def new_stall():
def
edit_stall
(
stall_id
):
def
edit_stall
(
stall_id
):
stall
=
Stall
.
query
.
get
(
stall_id
)
stall
=
Stall
.
query
.
get
(
stall_id
)
form
=
StallRegisterForm
()
form
=
StallRegisterForm
()
form
.
editing
=
True
form
.
location
.
choices
=
[(
loc
.
id
,
loc
.
name
)
for
loc
in
Location
.
query
.
all
()]
form
.
location
.
choices
=
[(
loc
.
id
,
loc
.
name
)
for
loc
in
Location
.
query
.
all
()]
if
request
.
method
==
'POST'
:
if
request
.
method
==
'POST'
:
if
form
.
validate
(
editing
=
True
):
if
form
.
validate
():
stall
.
name
=
form
.
name
.
data
stall
.
name
=
form
.
name
.
data
stall
.
description
=
form
.
description
.
data
stall
.
description
=
form
.
description
.
data
stall
.
location_id
=
form
.
location
.
data
stall
.
location_id
=
form
.
location
.
data
...
...
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