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
c37ec9f8
Commit
c37ec9f8
authored
Feb 23, 2015
by
Francesca Sargent
Browse files
Commenting to others
parent
f11231b9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
91 additions
and
8 deletions
+91
-8
flask/app/main/views.py
flask/app/main/views.py
+57
-8
flask/app/templates/_comments.html
flask/app/templates/_comments.html
+2
-0
flask/app/templates/cuisine.html
flask/app/templates/cuisine.html
+8
-0
flask/app/templates/flavour.html
flask/app/templates/flavour.html
+8
-0
flask/app/templates/ingredient.html
flask/app/templates/ingredient.html
+8
-0
flask/app/templates/method.html
flask/app/templates/method.html
+8
-0
No files found.
flask/app/main/views.py
View file @
c37ec9f8
...
...
@@ -473,28 +473,77 @@ def recipe(id):
flash
(
'Your comment has been published.'
)
return
redirect
(
url_for
(
'.recipe'
,
id
=
recipe
.
id
))
comments
=
Comment
.
query
.
filter_by
(
recipe
=
recipe
).
all
()
return
render_template
(
'recipe.html'
,
recipes
=
[
recipe
],
ingredients
=
ingredients
,
form
=
form
,
comments
=
comments
)
@
main
.
route
(
'/cuisine/<int:id>'
,
methods
=
[
'GET'
,
'POST'
])
def
cuisine
(
id
):
cuisine
=
[
Cuisine
.
query
.
get_or_404
(
id
)]
return
render_template
(
'cuisine.html'
,
cuisines
=
cuisine
)
cuisine
=
Cuisine
.
query
.
get_or_404
(
id
)
form
=
CommentForm
()
if
form
.
validate_on_submit
():
comment
=
Comment
(
body
=
form
.
body
.
data
,
cuisine
=
cuisine
,
author
=
current_user
.
_get_current_object
())
db
.
session
.
add
(
comment
)
flash
(
'Your comment has been published.'
)
return
redirect
(
url_for
(
'.cuisine'
,
id
=
cuisine
.
id
))
comments
=
Comment
.
query
.
filter_by
(
cuisine
=
cuisine
).
all
()
return
render_template
(
'cuisine.html'
,
cuisines
=
[
cuisine
],
form
=
form
,
comments
=
comments
)
@
main
.
route
(
'/method/<int:id>'
,
methods
=
[
'GET'
,
'POST'
])
def
method
(
id
):
method
=
[
Method
.
query
.
get_or_404
(
id
)]
return
render_template
(
'method.html'
,
methods
=
method
)
method
=
Method
.
query
.
get_or_404
(
id
)
form
=
CommentForm
()
if
form
.
validate_on_submit
():
comment
=
Comment
(
body
=
form
.
body
.
data
,
method
=
method
,
author
=
current_user
.
_get_current_object
())
db
.
session
.
add
(
comment
)
flash
(
'Your comment has been published.'
)
return
redirect
(
url_for
(
'.method'
,
id
=
method
.
id
))
comments
=
Comment
.
query
.
filter_by
(
method
=
method
).
all
()
return
render_template
(
'method.html'
,
methods
=
[
method
],
form
=
form
,
comments
=
comments
)
@
main
.
route
(
'/ingredient/<int:id>'
,
methods
=
[
'GET'
,
'POST'
])
def
ingredient
(
id
):
ingredient
=
[
Ingredient
.
query
.
get_or_404
(
id
)]
return
render_template
(
'ingredient.html'
,
ingredients
=
ingredient
)
ingredient
=
Ingredient
.
query
.
get_or_404
(
id
)
form
=
CommentForm
()
if
form
.
validate_on_submit
():
comment
=
Comment
(
body
=
form
.
body
.
data
,
ingredient
=
ingredient
,
author
=
current_user
.
_get_current_object
())
db
.
session
.
add
(
comment
)
flash
(
'Your comment has been published.'
)
return
redirect
(
url_for
(
'.ingredient'
,
id
=
ingredient
.
id
))
comments
=
Comment
.
query
.
filter_by
(
ingredient
=
ingredient
).
all
()
return
render_template
(
'ingredient.html'
,
ingredients
=
[
ingredient
],
form
=
form
,
comments
=
comments
)
@
main
.
route
(
'/flavour/<int:id>'
,
methods
=
[
'GET'
,
'POST'
])
def
flavour
(
id
):
flavour
=
[
FlavourType
.
query
.
get_or_404
(
id
)]
return
render_template
(
'flavour.html'
,
flavourtypes
=
flavour
,
type
=
'flavour'
)
flavour
=
FlavourType
.
query
.
get_or_404
(
id
)
form
=
CommentForm
()
if
form
.
validate_on_submit
():
comment
=
Comment
(
body
=
form
.
body
.
data
,
flavourtype
=
flavour
,
author
=
current_user
.
_get_current_object
())
db
.
session
.
add
(
comment
)
flash
(
'Your comment has been published.'
)
return
redirect
(
url_for
(
'.flavour'
,
id
=
flavour
.
id
))
comments
=
Comment
.
query
.
filter_by
(
flavourtype
=
flavour
).
all
()
return
render_template
(
'flavour.html'
,
flavourtypes
=
[
flavour
],
type
=
'flavour'
,
form
=
form
,
comments
=
comments
)
@
main
.
route
(
'/recipe/<int:id>/edit'
,
methods
=
[
'GET'
,
'POST'
])
@
login_required
...
...
flask/app/templates/_comments.html
View file @
c37ec9f8
{% if comments %}
<ul
class=
"comments"
>
{% for comment in comments %}
<li
class=
"comment"
>
...
...
@@ -33,3 +34,4 @@
</li>
{% endfor %}
</ul>
{% endif %}
flask/app/templates/cuisine.html
View file @
c37ec9f8
...
...
@@ -97,5 +97,13 @@ Created by <a href="{{ url_for('.user', username=cuisine.author.username) }}">{{
</div>
<h4
id=
"comments"
>
Comments
</h4>
{% if current_user.can(Permission.COMMENT) %}
<div
class=
"comment-form"
>
{{ wtf.quick_form(form) }}
</div>
{% endif %}
{% include '_comments.html' %}
{% endfor %}
{% endblock %}
flask/app/templates/flavour.html
View file @
c37ec9f8
...
...
@@ -42,5 +42,13 @@ Created by <a href="{{ url_for('.user', username=flavour.author.username) }}">{{
</div>
</div>
<h4
id=
"comments"
>
Comments
</h4>
{% if current_user.can(Permission.COMMENT) %}
<div
class=
"comment-form"
>
{{ wtf.quick_form(form) }}
</div>
{% endif %}
{% include '_comments.html' %}
{% endfor %}
{% endblock %}
flask/app/templates/ingredient.html
View file @
c37ec9f8
...
...
@@ -48,5 +48,13 @@ Created by <a href="{{ url_for('.user', username=ingredient.author.username) }}"
</div>
</div>
<h4
id=
"comments"
>
Comments
</h4>
{% if current_user.can(Permission.COMMENT) %}
<div
class=
"comment-form"
>
{{ wtf.quick_form(form) }}
</div>
{% endif %}
{% include '_comments.html' %}
{% endfor %}
{% endblock %}
flask/app/templates/method.html
View file @
c37ec9f8
...
...
@@ -52,5 +52,13 @@ Created by <a href="{{ url_for('.user', username=method.author.username) }}">{{
</div>
<h4
id=
"comments"
>
Comments
</h4>
{% if current_user.can(Permission.COMMENT) %}
<div
class=
"comment-form"
>
{{ wtf.quick_form(form) }}
</div>
{% endif %}
{% include '_comments.html' %}
{% endfor %}
{% endblock %}
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