mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2025-12-23 18:29:23 -05:00
added customizable Servings text
This commit is contained in:
18
cookbook/migrations/0100_recipe_servings_text.py
Normal file
18
cookbook/migrations/0100_recipe_servings_text.py
Normal 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),
|
||||
),
|
||||
]
|
||||
@@ -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
|
||||
|
||||
@@ -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
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user