Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
FoAM
open sauces
Commits
efed3abe
Commit
efed3abe
authored
Jan 22, 2015
by
Francesca Sargent
Browse files
Smoothing out Integrity Error
parent
de36a9f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
5 deletions
+17
-5
flask/app/main/views.py
flask/app/main/views.py
+17
-5
No files found.
flask/app/main/views.py
View file @
efed3abe
...
...
@@ -80,8 +80,11 @@ def poststuff(type):
if
current_user
.
can
(
Permission
.
WRITE_ARTICLES
)
and
\
form
.
validate_on_submit
():
methods
=
[
Method
(
name
=
form
.
methods
.
data
,
timestamp
=
'now'
,
author
=
current_user
.
_get_current_object
())]
if
Method
.
query
.
filter_by
(
name
=
form
.
methods
.
data
).
first
()
is
None
:
methods
=
[
Method
(
name
=
form
.
methods
.
data
,
timestamp
=
'now'
,
author
=
current_user
.
_get_current_object
())]
else
:
methods
=
[
Method
.
query
.
filter_by
(
name
=
form
.
methods
.
data
).
first
()]
cuisine
=
Cuisine
(
name
=
form
.
name
.
data
,
description
=
form
.
description
.
data
,
methods
=
methods
,
author
=
current_user
.
_get_current_object
())
...
...
@@ -94,7 +97,10 @@ def poststuff(type):
if
current_user
.
can
(
Permission
.
WRITE_ARTICLES
)
and
\
form
.
validate_on_submit
():
cuisines
=
[
Cuisine
(
name
=
form
.
cuisines
.
data
,
timestamp
=
'now'
,
author
=
current_user
.
_get_current_object
())]
if
Cuisine
.
query
.
filter_by
(
name
=
form
.
cuisines
.
data
).
first
()
is
None
:
cuisines
=
[
Cuisine
(
name
=
form
.
cuisines
.
data
,
timestamp
=
'now'
,
author
=
current_user
.
_get_current_object
())]
else
:
cuisines
=
[
Cuisine
.
query
.
filter_by
(
name
=
form
.
cuisines
.
data
).
first
()]
method
=
Method
(
name
=
form
.
name
.
data
,
...
...
@@ -307,7 +313,10 @@ def editmethod(id):
form
=
MethodForm
()
if
form
.
validate_on_submit
():
cuisines
=
[
Cuisine
(
name
=
form
.
cuisines
.
data
,
timestamp
=
'now'
,
author
=
current_user
.
_get_current_object
())]
if
Cuisine
.
query
.
filter_by
(
name
=
form
.
cuisines
.
data
).
first
()
is
None
:
cuisines
=
[
Cuisine
(
name
=
form
.
cuisines
.
data
,
timestamp
=
'now'
,
author
=
current_user
.
_get_current_object
())]
else
:
cuisines
=
[
Cuisine
.
query
.
filter_by
(
name
=
form
.
cuisines
.
data
).
first
()]
method
.
name
=
form
.
name
.
data
method
.
description
=
form
.
description
.
data
...
...
@@ -335,7 +344,10 @@ def editcuisine(id):
cuisine
.
name
=
form
.
name
.
data
cuisine
.
description
=
form
.
description
.
data
methods
=
[
Method
(
name
=
form
.
methods
.
data
,
author
=
current_user
.
_get_current_object
())]
if
Method
.
query
.
filter_by
(
name
=
form
.
methods
.
data
).
first
()
is
None
:
methods
=
[
Method
(
name
=
form
.
methods
.
data
,
timestamp
=
'now'
,
author
=
current_user
.
_get_current_object
())]
else
:
methods
=
[
Method
.
query
.
filter_by
(
name
=
form
.
methods
.
data
).
first
()]
cuisine
.
methods
.
extend
(
methods
)
db
.
session
.
add
(
cuisine
)
...
...
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