diff --git a/cookbook/forms.py b/cookbook/forms.py index d83bd528a..2642fe8ce 100644 --- a/cookbook/forms.py +++ b/cookbook/forms.py @@ -88,13 +88,14 @@ class InternalRecipeForm(forms.ModelForm): class Meta: model = Recipe - fields = ('name', 'image', 'working_time', 'waiting_time', 'keywords') + fields = ('name', 'image', 'working_time', 'waiting_time', 'servings', 'keywords') labels = { 'name': _('Name'), 'keywords': _('Keywords'), 'working_time': _('Preparation time in minutes'), 'waiting_time': _('Waiting time (cooking/baking) in minutes'), + 'servings': _('Number of servings'), } widgets = {'keywords': MultiSelectWidget} diff --git a/cookbook/migrations/0091_recipe_servings.py b/cookbook/migrations/0091_recipe_servings.py new file mode 100644 index 000000000..0b023bf7e --- /dev/null +++ b/cookbook/migrations/0091_recipe_servings.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.7 on 2020-08-30 13:32 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cookbook', '0090_auto_20201214_1359'), + ] + + operations = [ + migrations.AddField( + model_name='recipe', + name='servings', + field=models.IntegerField(default=1), + ), + ] diff --git a/cookbook/models.py b/cookbook/models.py index 7d1b09583..87d6e62fe 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -197,6 +197,7 @@ class NutritionInformation(models.Model): class Recipe(models.Model): name = models.CharField(max_length=128) + servings = models.IntegerField(default=1) image = models.ImageField(upload_to='recipes/', blank=True, null=True) storage = models.ForeignKey(Storage, on_delete=models.PROTECT, blank=True, null=True) file_uid = models.CharField(max_length=256, default="", blank=True) diff --git a/cookbook/serializer.py b/cookbook/serializer.py index 4b9a21d1c..e0800ed12 100644 --- a/cookbook/serializer.py +++ b/cookbook/serializer.py @@ -153,7 +153,7 @@ class RecipeSerializer(WritableNestedModelSerializer): class Meta: model = Recipe - fields = ['id', 'name', 'image', 'keywords', 'steps', 'working_time', 'waiting_time', 'created_by', 'created_at', 'updated_at', 'internal', 'nutrition'] + fields = ['id', 'name', 'image', 'keywords', 'steps', 'working_time', 'waiting_time', 'created_by', 'created_at', 'updated_at', 'internal', 'nutrition', 'servings'] read_only_fields = ['image', 'created_by', 'created_at'] diff --git a/cookbook/templates/forms/edit_internal_recipe.html b/cookbook/templates/forms/edit_internal_recipe.html index a71aab8e6..8d28581f0 100644 --- a/cookbook/templates/forms/edit_internal_recipe.html +++ b/cookbook/templates/forms/edit_internal_recipe.html @@ -62,6 +62,9 @@
+ + +
-
- [[element.name]] +
+ + [[element.name]] + + [[element.servings]]
@@ -140,7 +143,7 @@

+ placeholder="{% trans 'Serving Count' %}" style="margin-bottom: 8px">
@@ -243,6 +246,9 @@ {% trans 'Recipe' %}
[[ plan_detail.recipe_name ]]
+
+ {% trans 'Serving Count' %}
+ [[ plan_detail.recipe_multiplier ]]