Commit 2f0a492c authored by Francesca Sargent 's avatar Francesca Sargent
Browse files

Added inheritance of flavours throughout

parent a025eb10
......@@ -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)
......
......@@ -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)
......
......@@ -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">
......
......@@ -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 %}
......
......@@ -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 %}
......
......@@ -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">
......
......@@ -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 %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment