added customizable Servings text

This commit is contained in:
vabene1111
2021-01-21 20:05:46 +01:00
parent 32044907bf
commit 6992bf83aa
6 changed files with 25 additions and 3 deletions

View File

@@ -0,0 +1,18 @@
# Generated by Django 3.1.5 on 2021-01-21 19:02
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cookbook', '0099_auto_20210113_1518'),
]
operations = [
migrations.AddField(
model_name='recipe',
name='servings_text',
field=models.CharField(blank=True, default='', max_length=32),
),
]

View File

@@ -251,6 +251,7 @@ class Recipe(models.Model):
name = models.CharField(max_length=128)
description = models.CharField(max_length=512, blank=True, null=True)
servings = models.IntegerField(default=1)
servings_text = models.CharField(default='', blank=True, max_length=32)
image = models.ImageField(upload_to='recipes/', blank=True, null=True)
storage = models.ForeignKey(
Storage, on_delete=models.PROTECT, blank=True, null=True

View File

@@ -229,7 +229,7 @@ class RecipeSerializer(WritableNestedModelSerializer):
fields = (
'id', 'name', 'description', 'image', 'keywords', 'steps', 'working_time',
'waiting_time', 'created_by', 'created_at', 'updated_at',
'internal', 'nutrition', 'servings', 'file_path'
'internal', 'nutrition', 'servings', 'file_path', 'servings_text',
)
read_only_fields = ['image', 'created_by', 'created_at']

File diff suppressed because one or more lines are too long

View File

@@ -65,6 +65,9 @@
<label for="id_name"> {% trans 'Servings' %}</label>
<input class="form-control" id="id_servings" v-model="recipe.servings">
<br/>
<label for="id_name"> {% trans 'Servings Text' %}</label>
<input class="form-control" id="id_servings_text" v-model="recipe.servings_text" maxlength="32">
<br/>
<label for="id_name"> {% trans 'Keywords' %}</label>
<multiselect
v-model="recipe.keywords"

View File

@@ -59,7 +59,7 @@
type="number" class="form-control form-control-lg" v-model.number="servings"/>
</div>
<div class="my-auto">
<b>{{ _('Servings') }}</b>
<b><template v-if="recipe.servings_text === ''">{{ _('Servings') }}</template><template v-else>{{recipe.servings_text}}</template></b>
</div>
</div>
</div>