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
99b081bf
Commit
99b081bf
authored
Jan 21, 2015
by
Francesca Sargent
Browse files
Adding edit utility for Cuisine->Methods
parent
81ee32f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
8 deletions
+5
-8
flask/app/main/views.py
flask/app/main/views.py
+5
-8
No files found.
flask/app/main/views.py
View file @
99b081bf
...
...
@@ -84,12 +84,13 @@ def poststuff(type):
if
current_user
.
can
(
Permission
.
WRITE_ARTICLES
)
and
\
form
.
validate_on_submit
():
methods
=
[
Method
(
name
=
form
.
methods
.
data
,
author
=
current_user
.
_get_current_object
())]
methods
=
[
Method
(
name
=
form
.
methods
.
data
,
timestamp
=
'now'
,
author
=
current_user
.
_get_current_object
())]
cuisine
=
Cuisine
(
name
=
form
.
name
.
data
,
description
=
form
.
description
.
data
,
methods
=
methods
,
author
=
current_user
.
_get_current_object
())
db
.
session
.
add
(
cuisine
)
db
.
session
.
flush
()
return
redirect
(
url_for
(
'.index'
))
if
type
==
'method'
:
...
...
@@ -100,7 +101,6 @@ def poststuff(type):
name
=
form
.
name
.
data
,
description
=
form
.
description
.
data
,
method_text
=
form
.
method_text
.
data
,
# cuisines=form.cuisine.data,
author
=
current_user
.
_get_current_object
())
db
.
session
.
add
(
method
)
return
redirect
(
url_for
(
'.index'
))
...
...
@@ -117,7 +117,6 @@ def autocompletecuisine():
cuisines
=
[(
cuisine
.
name
)
for
cuisine
in
Cuisine
.
query
.
order_by
(
Cuisine
.
name
).
all
()]
# main.logger.debug(search)
return
jsonify
(
json_list
=
cuisines
)
@
main
.
route
(
'/autocompletemethod'
,
methods
=
[
'GET'
])
...
...
@@ -126,7 +125,6 @@ def autocompletemethod():
methods
=
[(
method
.
name
)
for
method
in
Method
.
query
.
order_by
(
Method
.
name
).
all
()]
# main.logger.debug(search)
return
jsonify
(
json_list
=
methods
)
#Recipe Page#
...
...
@@ -328,10 +326,9 @@ def editcuisine(id):
cuisine
.
name
=
form
.
name
.
data
cuisine
.
description
=
form
.
description
.
data
if
Method
.
query
.
filter
(
Method
.
name
==
form
.
methods
.
data
).
first
()
!=
None
:
methods
=
[
Method
.
query
.
filter
(
Method
.
name
==
form
.
methods
.
data
).
first
()]
else
:
methods
=
[
Method
(
name
=
form
.
methods
.
data
,
description
=
''
,
method_text
=
''
,
cuisines
=
[
Cuisine
.
query
.
filter
(
Cuisine
.
name
==
form
.
name
.
data
).
first
()],
author
=
current_user
.
_get_current_object
())]
methods
=
[
Method
(
name
=
form
.
methods
.
data
,
author
=
current_user
.
_get_current_object
())]
cuisine
.
methods
.
extend
(
methods
)
db
.
session
.
add
(
cuisine
)
flash
(
'The cuisine has been updated.'
)
...
...
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