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
3457c7bf
Commit
3457c7bf
authored
Jan 21, 2015
by
Francesca Sargent
Browse files
Editing Methods via Cuisine
parent
4029a051
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
flask/app/main/views.py
flask/app/main/views.py
+12
-4
No files found.
flask/app/main/views.py
View file @
3457c7bf
...
...
@@ -71,10 +71,6 @@ def poststuff(type):
recipe
=
Recipe
(
name
=
form
.
name
.
data
,
description
=
form
.
description
.
data
,
# cuisine=form.cuisine.data,
# cuisines = [Cuisine.query \
# .filter(Cuisine.name == form.cuisine.data) \
# .first()],
author
=
current_user
.
_get_current_object
())
db
.
session
.
add
(
recipe
)
return
redirect
(
url_for
(
'.index'
))
...
...
@@ -97,12 +93,17 @@ def poststuff(type):
form
=
MethodForm
()
if
current_user
.
can
(
Permission
.
WRITE_ARTICLES
)
and
\
form
.
validate_on_submit
():
cuisines
=
Cuisine
(
name
=
form
.
methods
.
data
,
timestamp
=
'now'
,
author
=
current_user
.
_get_current_object
())]
method
=
Method
(
name
=
form
.
name
.
data
,
description
=
form
.
description
.
data
,
method_text
=
form
.
method_text
.
data
,
cuisines
=
cuisines
,
author
=
current_user
.
_get_current_object
())
db
.
session
.
add
(
method
)
db
.
session
.
flush
()
return
redirect
(
url_for
(
'.index'
))
db
.
session
.
commit
()
...
...
@@ -279,6 +280,7 @@ def method(id):
@
main
.
route
(
'/recipe/<int:id>/edit'
,
methods
=
[
'GET'
,
'POST'
])
@
login_required
def
editrecipe
(
id
):
db
.
session
.
autoflush
=
True
recipe
=
Recipe
.
query
.
get_or_404
(
id
)
if
current_user
!=
recipe
.
author
and
\
not
current_user
.
can
(
Permission
.
ADMINISTER
):
...
...
@@ -297,14 +299,19 @@ def editrecipe(id):
@
main
.
route
(
'/method/<int:id>/edit'
,
methods
=
[
'GET'
,
'POST'
])
@
login_required
def
editmethod
(
id
):
db
.
session
.
autoflush
=
True
method
=
Method
.
query
.
get_or_404
(
id
)
if
current_user
!=
method
.
author
and
\
not
current_user
.
can
(
Permission
.
ADMINISTER
):
abort
(
403
)
form
=
MethodForm
()
if
form
.
validate_on_submit
():
cuisines
=
Cuisine
(
name
=
form
.
methods
.
data
,
timestamp
=
'now'
,
author
=
current_user
.
_get_current_object
())]
method
.
name
=
form
.
name
.
data
method
.
description
=
form
.
description
.
data
method
.
cuisines
.
extend
(
cuisines
)
method
.
method_text
=
form
.
method_text
.
data
db
.
session
.
add
(
method
)
flash
(
'The method has been updated.'
)
...
...
@@ -317,6 +324,7 @@ def editmethod(id):
@
main
.
route
(
'/cuisine/<int:id>/edit'
,
methods
=
[
'GET'
,
'POST'
])
@
login_required
def
editcuisine
(
id
):
db
.
session
.
autoflush
=
True
cuisine
=
Cuisine
.
query
.
get_or_404
(
id
)
if
current_user
!=
cuisine
.
author
and
\
not
current_user
.
can
(
Permission
.
ADMINISTER
):
...
...
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