From 77e778caacfddc53ace17e6626c9931090287f37 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Sat, 2 May 2020 00:49:29 +0200 Subject: [PATCH] new search design basics + Boostrap fixes --- cookbook/static/recipe_no_image.svg | 66 +++++ cookbook/tables.py | 12 +- cookbook/templates/base.html | 27 +- .../templates/generic/table_template.html | 2 +- cookbook/templates/index.html | 92 +++---- cookbook/templates/recipes_table.html | 87 +++++++ cookbook/templates/stats.html | 10 +- cookbook/templates/test.html | 240 ++++++++++++++++-- recipes/settings.py | 1 + 9 files changed, 450 insertions(+), 87 deletions(-) create mode 100644 cookbook/static/recipe_no_image.svg create mode 100644 cookbook/templates/recipes_table.html diff --git a/cookbook/static/recipe_no_image.svg b/cookbook/static/recipe_no_image.svg new file mode 100644 index 00000000..ba2976f6 --- /dev/null +++ b/cookbook/static/recipe_no_image.svg @@ -0,0 +1,66 @@ + + diff --git a/cookbook/tables.py b/cookbook/tables.py index ff7f0ca3..5c1fdde1 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 6a607063..dbd84928 100644 --- a/cookbook/templates/base.html +++ b/cookbook/templates/base.html @@ -54,20 +54,10 @@ {% block extra_head %} {% endblock %} - +