diff --git a/cookbook/admin.py b/cookbook/admin.py index 6fc1d1408..30522ffe9 100644 --- a/cookbook/admin.py +++ b/cookbook/admin.py @@ -147,7 +147,7 @@ admin.site.register(CookLog, CookLogAdmin) class ShoppingListRecipeAdmin(admin.ModelAdmin): - list_display = ('id', 'recipe', 'multiplier') + list_display = ('id', 'recipe', 'servings') admin.site.register(ShoppingListRecipe, ShoppingListRecipeAdmin) diff --git a/cookbook/forms.py b/cookbook/forms.py index 2642fe8ce..acacbec40 100644 --- a/cookbook/forms.py +++ b/cookbook/forms.py @@ -266,12 +266,11 @@ class MealPlanForm(forms.ModelForm): class Meta: model = MealPlan - fields = ('recipe', 'title', 'meal_type', 'note', 'recipe_multiplier', 'date', 'shared') + fields = ('recipe', 'title', 'meal_type', 'note', 'servings', 'date', 'shared') help_texts = { 'shared': _('You can list default users to share recipes with in the settings.'), - 'note': _('You can use markdown to format this field. See the docs here'), - 'recipe_multiplier': _('Scaling factor for recipe.') + 'note': _('You can use markdown to format this field. See the docs here') } widgets = {'recipe': SelectWidget, 'date': DateWidget, 'shared': MultiSelectWidget} diff --git a/cookbook/migrations/0093_auto_20201231_1236.py b/cookbook/migrations/0093_auto_20201231_1236.py new file mode 100644 index 000000000..45f1fd965 --- /dev/null +++ b/cookbook/migrations/0093_auto_20201231_1236.py @@ -0,0 +1,30 @@ +# Generated by Django 3.1.4 on 2020-12-31 11:36 + +import datetime +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cookbook', '0092_recipe_servings'), + ] + + operations = [ + migrations.RenameField( + model_name='mealplan', + old_name='recipe_multiplier', + new_name='servings', + ), + migrations.AlterField( + model_name='invitelink', + name='valid_until', + field=models.DateField(default=datetime.date(2021, 1, 14)), + ), + migrations.AlterField( + model_name='unit', + name='name', + field=models.CharField(max_length=128, unique=True, validators=[django.core.validators.MinLengthValidator(1)]), + ), + ] diff --git a/cookbook/migrations/0094_auto_20201231_1238.py b/cookbook/migrations/0094_auto_20201231_1238.py new file mode 100644 index 000000000..d46910651 --- /dev/null +++ b/cookbook/migrations/0094_auto_20201231_1238.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.4 on 2020-12-31 11:38 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('cookbook', '0093_auto_20201231_1236'), + ] + + operations = [ + migrations.RenameField( + model_name='shoppinglistrecipe', + old_name='multiplier', + new_name='servings', + ), + ] diff --git a/cookbook/models.py b/cookbook/models.py index 87d6e62fe..cdfd2fd51 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -272,7 +272,7 @@ class MealType(models.Model): class MealPlan(models.Model): recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE, blank=True, null=True) - recipe_multiplier = models.DecimalField(default=1, max_digits=8, decimal_places=4) + servings = models.DecimalField(default=1, max_digits=8, decimal_places=4) title = models.CharField(max_length=64, blank=True, default='') created_by = models.ForeignKey(User, on_delete=models.CASCADE) shared = models.ManyToManyField(User, blank=True, related_name='plan_share') @@ -294,7 +294,7 @@ class MealPlan(models.Model): class ShoppingListRecipe(models.Model): recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE, null=True, blank=True) - multiplier = models.DecimalField(default=1, max_digits=8, decimal_places=4) + servings = models.DecimalField(default=1, max_digits=8, decimal_places=4) def __str__(self): return f'Shopping list recipe {self.id} - {self.recipe}' diff --git a/cookbook/serializer.py b/cookbook/serializer.py index 05725c6e3..8992627c0 100644 --- a/cookbook/serializer.py +++ b/cookbook/serializer.py @@ -202,23 +202,23 @@ class MealPlanSerializer(serializers.ModelSerializer): recipe_name = serializers.ReadOnlyField(source='recipe.name') meal_type_name = serializers.ReadOnlyField(source='meal_type.name') note_markdown = serializers.SerializerMethodField('get_note_markdown') - recipe_multiplier = CustomDecimalField() + servings = CustomDecimalField() def get_note_markdown(self, obj): return markdown(obj.note) class Meta: model = MealPlan - fields = ('id', 'title', 'recipe', 'recipe_multiplier', 'note', 'note_markdown', 'date', 'meal_type', 'created_by', 'shared', 'recipe_name', 'meal_type_name') + fields = ('id', 'title', 'recipe', 'servings', 'note', 'note_markdown', 'date', 'meal_type', 'created_by', 'shared', 'recipe_name', 'meal_type_name') class ShoppingListRecipeSerializer(serializers.ModelSerializer): recipe_name = serializers.ReadOnlyField(source='recipe.name') - multiplier = CustomDecimalField() + servings = CustomDecimalField() class Meta: model = ShoppingListRecipe - fields = ('id', 'recipe', 'recipe_name', 'multiplier') + fields = ('id', 'recipe', 'recipe_name', 'servings') read_only_fields = ('id',) diff --git a/cookbook/templates/meal_plan.html b/cookbook/templates/meal_plan.html index ad0b22dc8..170df0bcf 100644 --- a/cookbook/templates/meal_plan.html +++ b/cookbook/templates/meal_plan.html @@ -142,7 +142,7 @@ class="text-muted">{% trans 'You can use markdown to format this field. See the docs here' %}

-

{% trans 'Serving Count' %}
- [[ plan_detail.recipe_multiplier ]] + [[ plan_detail.servings ]]