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
2f0a492c
Commit
2f0a492c
authored
Feb 20, 2015
by
Francesca Sargent
Browse files
Added inheritance of flavours throughout
parent
a025eb10
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
131 additions
and
6 deletions
+131
-6
flask/app/__init__.py
flask/app/__init__.py
+1
-0
flask/app/main/views.py
flask/app/main/views.py
+22
-1
flask/app/templates/_ingredients.html
flask/app/templates/_ingredients.html
+7
-2
flask/app/templates/_recipes.html
flask/app/templates/_recipes.html
+25
-1
flask/app/templates/cuisine.html
flask/app/templates/cuisine.html
+42
-2
flask/app/templates/ingredient.html
flask/app/templates/ingredient.html
+11
-0
flask/app/templates/recipe.html
flask/app/templates/recipe.html
+23
-0
No files found.
flask/app/__init__.py
View file @
2f0a492c
...
...
@@ -21,6 +21,7 @@ def create_app(config_name):
app
=
Flask
(
__name__
)
app
.
config
.
from_object
(
config
[
config_name
])
config
[
config_name
].
init_app
(
app
)
app
.
jinja_env
.
add_extension
(
'jinja2.ext.do'
)
bootstrap
.
init_app
(
app
)
mail
.
init_app
(
app
)
...
...
flask/app/main/views.py
View file @
2f0a492c
...
...
@@ -87,8 +87,27 @@ def postall(type):
page
,
per_page
=
current_app
.
config
[
'FLASKY_POSTS_PER_PAGE'
],
error_out
=
False
)
recipes
=
pagination
.
items
ingredients
=
[]
flavours
=
[]
for
recipe
in
recipes
:
for
step
in
recipe
.
steps
:
for
ingredient
in
step
.
ingredients
:
ingredients
.
append
(
ingredient
)
if
ingredient
.
name
in
ingredients
:
print
''
else
:
ingredients
.
append
(
ingredient
)
for
flavour
in
ingredient
.
flavours
:
flavours
.
append
(
flavour
)
ingredients
=
list
(
set
(
ingredients
))
flavours
=
list
(
set
(
flavours
))
return
render_template
(
'all_recipes.html'
,
user
=
user
,
recipes
=
recipes
,
pagination
=
pagination
,
type
=
type
)
pagination
=
pagination
,
type
=
type
,
flavours
=
flavours
,
ingredients
=
ingredients
)
if
type
==
'method'
:
query
=
Method
.
query
...
...
@@ -97,6 +116,8 @@ def postall(type):
page
,
per_page
=
current_app
.
config
[
'FLASKY_POSTS_PER_PAGE'
],
error_out
=
False
)
methods
=
pagination
.
items
return
render_template
(
'all_methods.html'
,
user
=
user
,
methods
=
methods
,
pagination
=
pagination
,
type
=
type
)
...
...
flask/app/templates/_ingredients.html
View file @
2f0a492c
...
...
@@ -2,9 +2,14 @@
{% for ingredient in ingredients %}
<li
class=
"recipe"
>
<div
class=
"recipe-content"
>
<p><h4>
{{ ingredient.name }}
</h4>
<p><h4>
<a
href=
"{{ url_for('.ingredient', id=ingredient.id) }}"
>
{{ ingredient.name }}
</a>
</h4>
Created by
<a
href=
"{{ url_for('.user', username=ingredient.author.username) }}"
>
{{ ingredient.author.username }}
</a></p>
Created by
<a
href=
"{{ url_for('.user', username=ingredient.author.username) }}"
>
{{ ingredient.author.username }}
</a><br/>
{% if ingredient.recipesteps.count() > 0 %}
<b>
Appears In:
</b>
{% for step in ingredient.recipesteps %}
<span
class=
"badge"
><a
href=
"{{ url_for('.recipe', id=step.recipe.id) }}"
>
{{ step.recipe.name }}
</a></span>
{% endfor %}
{% endif %}
</p>
<div
class=
"recipe-body"
>
...
...
flask/app/templates/_recipes.html
View file @
2f0a492c
...
...
@@ -17,12 +17,36 @@
{% if recipe.methods.count() > 0 %}
<strong>
Associated Methods:
</strong>
{% for method in recipe.methods %}
<span
class=
"badge"
>
{{ method.name }}
</span>
{% endfor %}
<br/>
{% endif %}
{% if recipe.description %}
{% set new_ingredients=[] %}
{% for ingredient in ingredients %}
{% for r in ingredient.recipesteps %}
{% if r.recipe_id == recipe.id %}
{% for ingredient in r.ingredients %}
{% if ingredient in new_ingredients %}
{% else %}
{% do new_ingredients.append(ingredient) %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endfor %}
{% if new_ingredients|length > 0 %}
<b>
Ingredients:
</b>
{% for ingredient in new_ingredients %}
<a
href=
"{{ url_for('.ingredient', id=ingredient.id) }}"
><span
class=
"badge"
>
{{ ingredient.name }}
</span></a>
{% endfor %}
{% endif %}
</p>
<p>
{% if recipe.description %}
{{ recipe.description }}
{% else %}
{{ recipe.description }}
{% endif %}
<br>
{% if recipe.cuisine %}
<span
class=
"label label-success"
>
{{ recipe.cuisine.name }}
</span>
{% endif %}
...
...
flask/app/templates/cuisine.html
View file @
2f0a492c
...
...
@@ -19,15 +19,55 @@ Created by <a href="{{ url_for('.user', username=cuisine.author.username) }}">{{
{% endif %}
{% if cuisine.recipes %}
<strong>
Recipes:
</strong>
{% for recipe in cuisine.recipes %}
<span
class=
"badge"
><a
href=
"{{ url_for('.recipe', id=recipe.id) }}"
>
{{ recipe.name }}
</a></span>
{% endfor %}
<br/>
<strong>
Ingredients:
</strong>
{% for recipe in cuisine.recipes %}
{% set new_ingredients=[] %}
{% for recipe in cuisine.recipes %}
{% for step in recipe.steps %}
{% if step.ingredients %}
{% for ingredient in step.ingredients %}
<span
class=
"badge"
><a
href=
"{{ url_for('.ingredient', id=ingredient.id) }}"
>
{{ ingredient.name }}
</a></span>
{% if ingredient in new_ingredients %}
{% else %}
{% do new_ingredients.append(ingredient) %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endfor %}
{% if new_ingredients|length > 0 %}
<b>
Ingredients:
</b>
{% for ingredient in new_ingredients %}
<a
href=
"{{ url_for('.ingredient', id=ingredient.id) }}"
><span
class=
"badge"
>
{{ ingredient.name }}
</span></a>
{% endfor %}
{% endif %}
<br/>
{% set new_flavours=[] %}
{% for recipe in cuisine.recipes %}
{% for step in recipe.steps %}
{% if step.ingredients %}
{% for ingredient in step.ingredients %}
{% if ingredient.flavours %}
{% for flavour in ingredient.flavours %}
{% if flavour in new_flavours %}
{% else %}
{% do new_flavours.append(flavour) %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endfor %}
{% if new_flavours|length > 0 %}
<b>
Flavours:
</b>
{% for flavour in new_flavours %}
<span
class=
"badge"
>
{{ flavour.flavourtype_name }}
</span>
{% endfor %}
{% endif %}
</p>
{% endif %}
<p>
{% if cuisine.description %}
...
...
flask/app/templates/ingredient.html
View file @
2f0a492c
...
...
@@ -11,6 +11,17 @@
<p><h4>
{{ ingredient.name }}
</h4>
Created by
<a
href=
"{{ url_for('.user', username=ingredient.author.username) }}"
>
{{ ingredient.author.username }}
</a></p>
{% if ingredient.recipesteps.count() > 0 %}
<b>
Appears In:
</b>
{% for step in ingredient.recipesteps %}
<span
class=
"badge"
><a
href=
"{{ url_for('.recipe', id=step.recipe.id) }}"
>
{{ step.recipe.name }}
</a></span>
{% endfor %}
<br/>
{% endif %}
{% if ingredient.flavours.count() > 0 %}
<b>
Flavours:
</b>
{% for flavour in ingredient.flavours %}
<span
class=
"badge"
>
{{ flavour.flavourtype_name }}
</span>
{% endfor %}
{% endif %}
</p>
<div
class=
"recipe-body"
>
...
...
flask/app/templates/recipe.html
View file @
2f0a492c
...
...
@@ -22,6 +22,29 @@ Created by <a href="{{ url_for('.user', username=recipe.author.username) }}">{{
<span
class=
"badge"
><a
href=
"{{ url_for('.ingredient', id=ingredient.id) }}"
>
{{ ingredient.name }}
</a></span>
{% endfor %}{% endif %}
</p>
{% set new_flavours = [] %}
{% for ingredient in ingredients %}
{% if ingredient.flavours %}
{% for flavour in ingredient.flavours %}
{% if flavour.flavourtype_name in new_flavours %}
{% else %}
{% do new_flavours.append(flavour) %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% if new_flavours|length > 0 %}
<b>
Flavours:
</b>
{% for flavour in new_flavours %}
<span
class=
"badge"
>
{{ flavour.flavourtype_name }}
</span>
{% endfor %}
{% endif %}
</p>
<p>
{% if recipe.description %}
{{ recipe.description }}
{% else %}
...
...
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