diff --git a/cookbook/forms.py b/cookbook/forms.py index 84c14ae1..8a2e3e8f 100644 --- a/cookbook/forms.py +++ b/cookbook/forms.py @@ -30,7 +30,7 @@ class UserPreferenceForm(forms.ModelForm): class Meta: model = UserPreference - fields = ('default_unit', 'theme', 'nav_color', 'default_page') + fields = ('default_unit', 'theme', 'nav_color', 'default_page', 'search_style') help_texts = { 'nav_color': _('Color of the top navigation bar. Not all colors work with all themes, just try them out!'), diff --git a/cookbook/migrations/0037_userpreference_search_style.py b/cookbook/migrations/0037_userpreference_search_style.py new file mode 100644 index 00000000..c90e3fed --- /dev/null +++ b/cookbook/migrations/0037_userpreference_search_style.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.5 on 2020-05-02 10:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cookbook', '0036_auto_20200427_1800'), + ] + + operations = [ + migrations.AddField( + model_name='userpreference', + name='search_style', + field=models.CharField(choices=[('SMALL', 'Small'), ('LARGE', 'Large')], default='LARGE', max_length=64), + ), + ] diff --git a/cookbook/models.py b/cookbook/models.py index 1e0f400a..ce25d1e7 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -48,11 +48,18 @@ class UserPreference(models.Model): PAGES = ((SEARCH, _('Search')), (PLAN, _('Meal-Plan')), (BOOKS, _('Books')), ) + # Search Style + SMALL = 'SMALL' + LARGE = 'LARGE' + + SEARCH_STYLE = ((SMALL, _('Small')), (LARGE, _('Large')),) + user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True) theme = models.CharField(choices=THEMES, max_length=128, default=FLATLY) nav_color = models.CharField(choices=COLORS, max_length=128, default=PRIMARY) default_unit = models.CharField(max_length=32, default='g') default_page = models.CharField(choices=PAGES, max_length=64, default=SEARCH) + search_style = models.CharField(choices=SEARCH_STYLE, max_length=64, default=LARGE) def __str__(self): return self.user diff --git a/cookbook/tables.py b/cookbook/tables.py index a23d3be2..a0466c9a 100644 --- a/cookbook/tables.py +++ b/cookbook/tables.py @@ -13,6 +13,18 @@ class ImageUrlColumn(tables.Column): return None +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'}}) + + class Meta: + model = Recipe + template_name = 'generic/table_template.html' + fields = ('id', 'name', 'all_tags') + + class RecipeTable(tables.Table): edit = tables.TemplateColumn("" + _('Edit') + "") name = tables.LinkColumn('view_recipe', args=[A('id')]) diff --git a/cookbook/templates/recipes_table.html b/cookbook/templates/recipes_table.html index 61838540..2822861a 100644 --- a/cookbook/templates/recipes_table.html +++ b/cookbook/templates/recipes_table.html @@ -11,11 +11,9 @@ {% block table %}