diff --git a/cookbook/tables.py b/cookbook/tables.py index a29a75366..a5c1cca82 100644 --- a/cookbook/tables.py +++ b/cookbook/tables.py @@ -1,9 +1,10 @@ import django_tables2 as tables from django.utils.html import format_html from django.utils.translation import gettext as _ -from django_tables2.utils import A # alias for Accessor +from django_tables2.utils import A -from .models import * +from .models import (CookLog, InviteLink, Keyword, Recipe, RecipeImport, + ShoppingList, Storage, Sync, SyncLog, ViewLog) class ImageUrlColumn(tables.Column): @@ -17,7 +18,11 @@ class RecipeTableSmall(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'}}) + attrs={ + 'td': {'class': 'd-none d-lg-table-cell'}, + 'th': {'class': 'd-none d-lg-table-cell'} + } + ) class Meta: model = Recipe @@ -26,16 +31,25 @@ class RecipeTableSmall(tables.Table): class RecipeTable(tables.Table): - edit = tables.TemplateColumn("" + _('Edit') + "") + edit = tables.TemplateColumn( + "" + _('Edit') + "" # noqa: E501 + ) 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'}}) + 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 = 'recipes_table.html' - fields = ('id', 'name', 'all_tags', 'image', 'instructions', 'working_time', 'waiting_time', 'internal') + fields = ( + 'id', 'name', 'all_tags', 'image', 'instructions', + 'working_time', 'waiting_time', 'internal' + ) class KeywordTable(tables.Table): @@ -71,9 +85,13 @@ class ImportLogTable(tables.Table): @staticmethod def render_status(value): if value == 'SUCCESS': - return format_html('%s' % value) + return format_html( + '%s' % value + ) else: - return format_html('%s' % value) + return format_html( + '%s' % value + ) class Meta: model = SyncLog @@ -90,7 +108,9 @@ class SyncTable(tables.Table): @staticmethod def render_storage(value): - return format_html('%s' % value) + return format_html( + '%s' % value + ) class Meta: model = Sync @@ -100,7 +120,9 @@ class SyncTable(tables.Table): class RecipeImportTable(tables.Table): id = tables.LinkColumn('new_recipe_import', args=[A('id')]) - delete = tables.TemplateColumn("" + _('Delete') + "") + delete = tables.TemplateColumn( + "" + _('Delete') + "" # noqa: E501 + ) class Meta: model = RecipeImport @@ -118,13 +140,19 @@ class ShoppingListTable(tables.Table): class InviteLinkTable(tables.Table): - link = tables.TemplateColumn("" + _('Link') + "") - delete = tables.TemplateColumn("" + _('Delete') + "") + link = tables.TemplateColumn( + "" + _('Link') + "" + ) + delete = tables.TemplateColumn( + "" + _('Delete') + "" # noqa: E501 + ) class Meta: model = InviteLink template_name = 'generic/table_template.html' - fields = ('username', 'group', 'valid_until', 'created_by', 'created_at') + fields = ( + 'username', 'group', 'valid_until', 'created_by', 'created_at' + ) class ViewLogTable(tables.Table):