Skip to content

Commit

Permalink
Move ingredient (foodstuff detail) url to food app
Browse files Browse the repository at this point in the history
Improve url naming
Show recipe/ingredient/category selectors on all pages
  • Loading branch information
grahamu committed Sep 19, 2021
1 parent 85ccb18 commit 83ad908
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
27 changes: 27 additions & 0 deletions flyingcracker/food/templates/food/category_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% extends "cocktail.html" %}

{% block body %}
<div class="cocktail">
<div class="box">
<div class="header">
<div class="title">
{{ category|capfirst }} {{ recipe_type|capfirst }} Recipes
</div>
</div>
{% if matching_recipes %}
<div class="bd">
{% for recipe in matching_recipes %}
<div class="yui-gd">
<div class="yui-u first"><a href="{% url 'food:recipe-detail' recipe_type=recipe_type slug=recipe.slug %}">{{ recipe.title }}</a></div>
<div class="yui-u">{{ recipe.teaser }}</div>
</div>
{% endfor %}
</div>
{% else %}
<p>No {{ recipe_type }} recipes in the database.</p>
{% endif %}
<br />
{% include "food/food_select.html" %}
</div>
</div>
{% endblock %}
5 changes: 3 additions & 2 deletions flyingcracker/food/templates/food/foodstuff_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<table>
{% for foodstuff in all_foodstuff %}
<tr>
<td><a href="{% url 'food:ingredient-detail' recipe_type=recipe_type slug=foodstuff.slug %}">{{ foodstuff }}</a></td>
<td><a href="{% url 'food:ingredient-detail' recipe_type=recipe_type slug=foodstuff.slug %}">{{
foodstuff }}</a></td>
</tr>
{% endfor %}
</table>
Expand All @@ -26,4 +27,4 @@
</div>
</div>

{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion flyingcracker/food/templates/food/recipe_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="box">
<div class="header">
<div class="title">
All {% if category %}{{ category|capfirst }} {% endif %}{{ recipe_type|capfirst }} Recipes
All {{ recipe_type|capfirst }} Recipes
</div>
</div>
{% if matching_recipes %}
Expand Down
4 changes: 2 additions & 2 deletions flyingcracker/food/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

app_name = 'food'
urlpatterns = [
re_path(r'^ingredients/$', views.foodstuff_list, name='ingredient-list'),
re_path(r'^i/(?P<slug>[\w_-]+)/$', views.foodstuff_detail, name='ingredient-detail'),
re_path(r'^c/(?P<slug>[\w_-]+)/$', views.category_detail, name='category-detail'),
re_path(r'^i/(?P<slug>[\w_-]+)/$', views.foodstuff_detail, name='ingredient-detail'),
re_path(r'^ingredients/$', views.foodstuff_list, name='ingredient-list'),
re_path(r'^(?P<slug>[\w_-]+)/$', views.recipe_detail, name='recipe-detail'),
re_path(r'^$', views.recipe_list, name='recipe-list'),
]
2 changes: 1 addition & 1 deletion flyingcracker/food/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def category_detail(request, recipe_type, slug):
'matching_recipes': category_recipes,
'recipe_type': recipe_type,
}
return render(request, 'food/recipe_list.html', context)
return render(request, 'food/category_list.html', context)


def get_all_lists(recipe_type):
Expand Down

0 comments on commit 83ad908

Please sign in to comment.