Skip to content

Commit

Permalink
recipe editor decimal fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vabene1111 committed Jan 17, 2022
1 parent a19ad70 commit 306f90a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cookbook/serializer.py
Expand Up @@ -496,6 +496,11 @@ class Meta:


class NutritionInformationSerializer(serializers.ModelSerializer):
carbohydrates = CustomDecimalField()
fats = CustomDecimalField()
proteins = CustomDecimalField()
calories = CustomDecimalField()


def create(self, validated_data):
validated_data['space'] = self.context['request'].space
Expand Down
2 changes: 2 additions & 0 deletions vue/src/apps/RecipeEditView/RecipeEditView.vue
Expand Up @@ -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
}
Expand Down

0 comments on commit 306f90a

Please sign in to comment.