diff --git a/cookbook/static/recipe_no_image.svg b/cookbook/static/recipe_no_image.svg new file mode 100644 index 000000000..ba2976f63 --- /dev/null +++ b/cookbook/static/recipe_no_image.svg @@ -0,0 +1,66 @@ + + diff --git a/cookbook/tables.py b/cookbook/tables.py index ff7f0ca38..5c1fdde18 100644 --- a/cookbook/tables.py +++ b/cookbook/tables.py @@ -6,16 +6,24 @@ from django_tables2.utils import A # alias for Accessor from .models import * +class ImageUrlColumn(tables.Column): + def render(self, value): + if value.url: + return value.url + return None + + class RecipeTable(tables.Table): id = tables.LinkColumn('edit_recipe', args=[A('id')]) name = tables.LinkColumn('view_recipe', args=[A('id')]) all_tags = tables.Column( attrs={'td': {'class': 'd-none d-lg-table-cell'}, 'th': {'class': 'd-none d-lg-table-cell'}}) + image = ImageUrlColumn() class Meta: model = Recipe - template_name = 'generic/table_template.html' - fields = ('id', 'name', 'all_tags') + template_name = 'recipes_table.html' + fields = ('id', 'name', 'all_tags', 'image', 'instructions') class KeywordTable(tables.Table): diff --git a/cookbook/templates/base.html b/cookbook/templates/base.html index 6a607063a..dbd849281 100644 --- a/cookbook/templates/base.html +++ b/cookbook/templates/base.html @@ -54,20 +54,10 @@ {% block extra_head %} {% endblock %} - +