From 27c695a393117b994ecf983a6a96f3779d19d691 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Sun, 26 Jun 2022 12:36:37 +0200 Subject: [PATCH] allow disabling of ingredient overview --- .../0177_recipe_show_ingredient_overview.py | 18 +++++++++++++ cookbook/models.py | 1 + cookbook/serializer.py | 2 +- .../apps/RecipeEditView/RecipeEditView.vue | 26 ++++++++++++++----- vue/src/apps/RecipeView/RecipeView.vue | 2 +- vue/src/locales/en.json | 2 ++ vue/src/utils/openapi/api.ts | 6 +++++ 7 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 cookbook/migrations/0177_recipe_show_ingredient_overview.py diff --git a/cookbook/migrations/0177_recipe_show_ingredient_overview.py b/cookbook/migrations/0177_recipe_show_ingredient_overview.py new file mode 100644 index 000000000..a67d75145 --- /dev/null +++ b/cookbook/migrations/0177_recipe_show_ingredient_overview.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.4 on 2022-06-26 10:26 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cookbook', '0176_alter_searchpreference_icontains_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='recipe', + name='show_ingredient_overview', + field=models.BooleanField(default=True), + ), + ] diff --git a/cookbook/models.py b/cookbook/models.py index b9347e0f1..8bd2e22c5 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -747,6 +747,7 @@ class Recipe(ExportModelOperationsMixin('recipe'), models.Model, PermissionModel waiting_time = models.IntegerField(default=0) internal = models.BooleanField(default=False) nutrition = models.ForeignKey(NutritionInformation, blank=True, null=True, on_delete=models.CASCADE) + show_ingredient_overview = models.BooleanField(default=True) source_url = models.CharField(max_length=1024, default=None, blank=True, null=True) created_by = models.ForeignKey(User, on_delete=models.PROTECT) diff --git a/cookbook/serializer.py b/cookbook/serializer.py index 124a47bab..e5b5c3963 100644 --- a/cookbook/serializer.py +++ b/cookbook/serializer.py @@ -708,7 +708,7 @@ class RecipeSerializer(RecipeBaseSerializer): fields = ( 'id', 'name', 'description', 'image', 'keywords', 'steps', 'working_time', 'waiting_time', 'created_by', 'created_at', 'updated_at', 'source_url', - 'internal', 'nutrition', 'servings', 'file_path', 'servings_text', 'rating', 'last_cooked', + 'internal', 'show_ingredient_overview','nutrition', 'servings', 'file_path', 'servings_text', 'rating', 'last_cooked', ) read_only_fields = ['image', 'created_by', 'created_at'] diff --git a/vue/src/apps/RecipeEditView/RecipeEditView.vue b/vue/src/apps/RecipeEditView/RecipeEditView.vue index 2bdbdb514..bc088d349 100644 --- a/vue/src/apps/RecipeEditView/RecipeEditView.vue +++ b/vue/src/apps/RecipeEditView/RecipeEditView.vue @@ -19,8 +19,14 @@ - + + + + + @@ -88,6 +94,11 @@ > +
+ + {{$t('show_ingredient_overview')}} + +
@@ -558,7 +569,8 @@
@@ -608,7 +620,7 @@
@@ -623,11 +635,13 @@
-
diff --git a/vue/src/apps/RecipeView/RecipeView.vue b/vue/src/apps/RecipeView/RecipeView.vue index 41a370765..c2774081c 100644 --- a/vue/src/apps/RecipeView/RecipeView.vue +++ b/vue/src/apps/RecipeView/RecipeView.vue @@ -82,7 +82,7 @@
+ v-if="recipe && ingredient_count > 0 && (recipe.show_ingredient_overview || recipe.steps.length < 2)">