From 306f90aa98020c6620bb9e11cd8b12ac31abbc39 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Mon, 17 Jan 2022 16:27:10 +0100 Subject: [PATCH] recipe editor decimal fixes --- cookbook/serializer.py | 5 +++++ vue/src/apps/RecipeEditView/RecipeEditView.vue | 2 ++ 2 files changed, 7 insertions(+) diff --git a/cookbook/serializer.py b/cookbook/serializer.py index fb1c3a224..06d09c216 100644 --- a/cookbook/serializer.py +++ b/cookbook/serializer.py @@ -496,6 +496,11 @@ class StepRecipeSerializer(WritableNestedModelSerializer): class NutritionInformationSerializer(serializers.ModelSerializer): + carbohydrates = CustomDecimalField() + fats = CustomDecimalField() + proteins = CustomDecimalField() + calories = CustomDecimalField() + def create(self, validated_data): validated_data['space'] = self.context['request'].space diff --git a/vue/src/apps/RecipeEditView/RecipeEditView.vue b/vue/src/apps/RecipeEditView/RecipeEditView.vue index 09ceb6e07..9b8f081d6 100644 --- a/vue/src/apps/RecipeEditView/RecipeEditView.vue +++ b/vue/src/apps/RecipeEditView/RecipeEditView.vue @@ -586,6 +586,8 @@ export default { if (this.recipe.working_time === "" || isNaN(this.recipe.working_time)) { this.recipe.working_time = 0 } + + this.recipe.servings = Math.floor(this.recipe.servings) // temporary fix until a proper framework for frontend input validation is established if (this.recipe.servings === "" || isNaN(this.recipe.servings)) { this.recipe.servings = 0 }