From 1d2976b687c615996cb6e3ea205d0c1eacff5508 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Wed, 8 Jul 2020 21:23:41 +0200 Subject: [PATCH] create default step + view time improvement --- cookbook/templates/recipe_view.html | 9 +++++---- cookbook/views/new.py | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cookbook/templates/recipe_view.html b/cookbook/templates/recipe_view.html index 66a20b1c..8f9dc6d9 100644 --- a/cookbook/templates/recipe_view.html +++ b/cookbook/templates/recipe_view.html @@ -233,7 +233,7 @@ {% endif %} {% if s.name %}{{ s.name }}{% else %}{% trans 'Step' %} {{ forloop.counter }}{% endif %} - {% if s.type == 'TIME' %} + {% if s.time != 0 %} - {{ s.time }} {% trans 'Minutes' %} {% endif %} @@ -242,11 +242,8 @@ @change="updateTimes(recipe.steps[{{ forloop.counter0 }}])" v-model="recipe.steps[{{ forloop.counter0 }}].time_finished"> - - -
0) { this.has_ingredients = true } + if (step.time !== 0) { + this.has_times = true + } this.$set(step, 'time_finished', undefined) for (let i of step.ingredients) { this.$set(i, 'checked', false) diff --git a/cookbook/views/new.py b/cookbook/views/new.py index 6eebb227..f2fdd925 100644 --- a/cookbook/views/new.py +++ b/cookbook/views/new.py @@ -11,7 +11,7 @@ from django.views.generic import CreateView from cookbook.forms import ImportRecipeForm, RecipeImport, KeywordForm, Storage, StorageForm, InternalRecipeForm, \ RecipeBookForm, MealPlanForm from cookbook.helper.permission_helper import GroupRequiredMixin, group_required -from cookbook.models import Keyword, Recipe, RecipeBook, MealPlan, ShareLink, MealType +from cookbook.models import Keyword, Recipe, RecipeBook, MealPlan, ShareLink, MealType, Step class RecipeCreate(GroupRequiredMixin, CreateView): @@ -25,6 +25,7 @@ class RecipeCreate(GroupRequiredMixin, CreateView): obj.created_by = self.request.user obj.internal = True obj.save() + obj.steps.add(Step.objects.create()) return HttpResponseRedirect(reverse('edit_recipe', kwargs={'pk': obj.pk})) def get_success_url(self):