added recipe steps
This commit is contained in:
1
.idea/recipes.iml
generated
1
.idea/recipes.iml
generated
@ -14,6 +14,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="NewModuleRootManager">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/cookbook/tests/resources" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/staticfiles" />
|
<excludeFolder url="file://$MODULE_DIR$/staticfiles" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||||
</content>
|
</content>
|
||||||
|
@ -84,19 +84,15 @@ class InternalRecipeForm(forms.ModelForm):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Recipe
|
model = Recipe
|
||||||
fields = ('name', 'instructions', 'image', 'working_time', 'waiting_time', 'keywords')
|
fields = ('name', 'image', 'working_time', 'waiting_time', 'keywords')
|
||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
'name': _('Name'),
|
'name': _('Name'),
|
||||||
'keywords': _('Keywords'),
|
'keywords': _('Keywords'),
|
||||||
'instructions': _('Instructions'),
|
|
||||||
'working_time': _('Preparation time in minutes'),
|
'working_time': _('Preparation time in minutes'),
|
||||||
'waiting_time': _('Waiting time (cooking/baking) in minutes'),
|
'waiting_time': _('Waiting time (cooking/baking) in minutes'),
|
||||||
}
|
}
|
||||||
widgets = {'keywords': MultiSelectWidget}
|
widgets = {'keywords': MultiSelectWidget}
|
||||||
help_texts = {
|
|
||||||
'instructions': _('You can use markdown to format this field. See the <a href="/docs/markdown/">docs here</a>')
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ShoppingForm(forms.Form):
|
class ShoppingForm(forms.Form):
|
||||||
|
14
cookbook/migrations/0061_merge_20200625_2209.py
Normal file
14
cookbook/migrations/0061_merge_20200625_2209.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Generated by Django 3.0.7 on 2020-06-25 20:09
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('cookbook', '0056_auto_20200625_2157'),
|
||||||
|
('cookbook', '0060_auto_20200625_2144'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
]
|
47
cookbook/migrations/0062_auto_20200625_2219.py
Normal file
47
cookbook/migrations/0062_auto_20200625_2219.py
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# Generated by Django 3.0.7 on 2020-06-25 20:19
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
def create_default_step(apps, schema_editor):
|
||||||
|
Recipe = apps.get_model('cookbook', 'Recipe')
|
||||||
|
Step = apps.get_model('cookbook', 'Step')
|
||||||
|
|
||||||
|
for r in Recipe.objects.filter(internal=True).all():
|
||||||
|
s = Step.objects.create(
|
||||||
|
instruction=r.instructions
|
||||||
|
)
|
||||||
|
for i in r.ingredients.all():
|
||||||
|
s.ingredients.add(i)
|
||||||
|
s.save()
|
||||||
|
r.steps.add(s)
|
||||||
|
r.save()
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
('cookbook', '0061_merge_20200625_2209'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='recipe',
|
||||||
|
name='ingredients',
|
||||||
|
field=models.ManyToManyField(blank=True, to='cookbook.Ingredient'),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Step',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('kind', models.CharField(choices=[('TEXT', 'Text')], default='TEXT', max_length=16)),
|
||||||
|
('instruction', models.TextField(blank=True)),
|
||||||
|
('ingredients', models.ManyToManyField(blank=True, to='cookbook.Ingredient')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='recipe',
|
||||||
|
name='steps',
|
||||||
|
field=models.ManyToManyField(blank=True, to='cookbook.Step'),
|
||||||
|
),
|
||||||
|
migrations.RunPython(create_default_step)
|
||||||
|
]
|
21
cookbook/migrations/0063_auto_20200625_2230.py
Normal file
21
cookbook/migrations/0063_auto_20200625_2230.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Generated by Django 3.0.7 on 2020-06-25 20:30
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('cookbook', '0062_auto_20200625_2219'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='recipe',
|
||||||
|
name='ingredients',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='recipe',
|
||||||
|
name='instructions',
|
||||||
|
),
|
||||||
|
]
|
@ -125,25 +125,6 @@ class Keyword(models.Model):
|
|||||||
else:
|
else:
|
||||||
return f"{self.name}"
|
return f"{self.name}"
|
||||||
|
|
||||||
|
|
||||||
class Recipe(models.Model):
|
|
||||||
name = models.CharField(max_length=128)
|
|
||||||
instructions = models.TextField(blank=True)
|
|
||||||
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="")
|
|
||||||
file_path = models.CharField(max_length=512, default="")
|
|
||||||
link = models.CharField(max_length=512, null=True, blank=True)
|
|
||||||
cors_link = models.CharField(max_length=1024, null=True, blank=True)
|
|
||||||
keywords = models.ManyToManyField(Keyword, blank=True)
|
|
||||||
ingredients = models.ManyToManyField('Ingredient', blank=True, related_name='tmp_ingredients')
|
|
||||||
working_time = models.IntegerField(default=0)
|
|
||||||
waiting_time = models.IntegerField(default=0)
|
|
||||||
internal = models.BooleanField(default=False)
|
|
||||||
created_by = models.ForeignKey(User, on_delete=models.PROTECT)
|
|
||||||
created_at = models.DateTimeField(auto_now_add=True)
|
|
||||||
updated_at = models.DateTimeField(auto_now=True)
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
@ -158,7 +139,7 @@ class Unit(models.Model):
|
|||||||
|
|
||||||
class Food(models.Model):
|
class Food(models.Model):
|
||||||
name = models.CharField(unique=True, max_length=128)
|
name = models.CharField(unique=True, max_length=128)
|
||||||
recipe = models.ForeignKey(Recipe, null=True, blank=True, on_delete=models.SET_NULL)
|
recipe = models.ForeignKey('Recipe', null=True, blank=True, on_delete=models.SET_NULL)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
@ -174,6 +155,32 @@ class Ingredient(models.Model):
|
|||||||
return str(self.amount) + ' ' + str(self.unit) + ' ' + str(self.food)
|
return str(self.amount) + ' ' + str(self.unit) + ' ' + str(self.food)
|
||||||
|
|
||||||
|
|
||||||
|
class Step(models.Model):
|
||||||
|
TEXT = 'TEXT'
|
||||||
|
|
||||||
|
kind = models.CharField(choices=((TEXT, _('Text')),), default=TEXT, max_length=16)
|
||||||
|
instruction = models.TextField(blank=True)
|
||||||
|
ingredients = models.ManyToManyField(Ingredient, blank=True)
|
||||||
|
|
||||||
|
|
||||||
|
class Recipe(models.Model):
|
||||||
|
name = models.CharField(max_length=128)
|
||||||
|
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="")
|
||||||
|
file_path = models.CharField(max_length=512, default="")
|
||||||
|
link = models.CharField(max_length=512, null=True, blank=True)
|
||||||
|
cors_link = models.CharField(max_length=1024, null=True, blank=True)
|
||||||
|
keywords = models.ManyToManyField(Keyword, blank=True)
|
||||||
|
steps = models.ManyToManyField(Step, blank=True)
|
||||||
|
working_time = models.IntegerField(default=0)
|
||||||
|
waiting_time = models.IntegerField(default=0)
|
||||||
|
internal = models.BooleanField(default=False)
|
||||||
|
created_by = models.ForeignKey(User, on_delete=models.PROTECT)
|
||||||
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
|
updated_at = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
|
|
||||||
class Comment(models.Model):
|
class Comment(models.Model):
|
||||||
recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE)
|
recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE)
|
||||||
text = models.TextField()
|
text = models.TextField()
|
||||||
|
@ -103,7 +103,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{% if recipe.ingredients %}
|
{% if recipe.steps %}
|
||||||
<div class="col-md-6 order-md-1 col-sm-12 order-sm-2 col-12 order-2">
|
<div class="col-md-6 order-md-1 col-sm-12 order-sm-2 col-12 order-2">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@ -124,61 +124,63 @@
|
|||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
<table class="table table-sm">
|
<table class="table table-sm">
|
||||||
{% for i in recipe.ingredients.all %}
|
{% for s in recipe.steps.all %}
|
||||||
{% if i.unit.name == 'Special:Header' %}
|
{% for i in s.ingredients.all %}
|
||||||
<tr>
|
{% if i.unit.name == 'Special:Header' %}
|
||||||
<td style="padding-top: 8px!important; ">
|
<tr>
|
||||||
<b>{{ i.note }}</b>
|
<td style="padding-top: 8px!important; ">
|
||||||
</td>
|
<b>{{ i.note }}</b>
|
||||||
<td>
|
</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% else %}
|
{% else %}
|
||||||
<tr>
|
<tr>
|
||||||
<td style="vertical-align: middle!important;">
|
<td style="vertical-align: middle!important;">
|
||||||
<div class="pretty p-default p-curve">
|
<div class="pretty p-default p-curve">
|
||||||
<input type="checkbox"/>
|
<input type="checkbox"/>
|
||||||
<div class="state p-success">
|
<div class="state p-success">
|
||||||
<label>
|
<label>
|
||||||
{% if i.amount != 0 %}
|
{% if i.amount != 0 %}
|
||||||
<span id="ing_{{ i.pk }}">{{ i.amount.normalize }}</span>
|
<span id="ing_{{ i.pk }}">{{ i.amount.normalize }}</span>
|
||||||
{{ i.unit }}
|
{{ i.unit }}
|
||||||
{% else %}
|
{% else %}
|
||||||
<span>⁣</span>
|
<span>⁣</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</label>
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td style="vertical-align: middle!important;">
|
<td style="vertical-align: middle!important;">
|
||||||
{% if i.food.recipe %}
|
{% if i.food.recipe %}
|
||||||
<a href="{% url 'view_recipe' i.food.recipe.pk %}"
|
<a href="{% url 'view_recipe' i.food.recipe.pk %}"
|
||||||
target="_blank" rel="noopener noreferrer">
|
target="_blank" rel="noopener noreferrer">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ i.food.name }}
|
{{ i.food.name }}
|
||||||
{% if i.food.recipe %}
|
{% if i.food.recipe %}
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td style="vertical-align: middle!important;">
|
<td style="vertical-align: middle!important;">
|
||||||
{% if i.note %}
|
{% if i.note %}
|
||||||
<a class="btn btn-light btn-sm d-print-none" tabindex="-1"
|
<a class="btn btn-light btn-sm d-print-none" tabindex="-1"
|
||||||
data-toggle="popover"
|
data-toggle="popover"
|
||||||
data-placement="right" data-html="true" data-trigger="focus"
|
data-placement="right" data-html="true" data-trigger="focus"
|
||||||
data-content="{{ i.note }}">
|
data-content="{{ i.note }}">
|
||||||
<i class="fas fa-info"></i>
|
<i class="fas fa-info"></i>
|
||||||
</a>
|
</a>
|
||||||
<div class="d-none d-print-block">
|
<div class="d-none d-print-block">
|
||||||
<i class="far fa-comment-alt"></i> {{ i.note }}
|
<i class="far fa-comment-alt"></i> {{ i.note }}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<!-- Bottom border -->
|
<!-- Bottom border -->
|
||||||
<tr>
|
<tr>
|
||||||
@ -209,9 +211,11 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div style="font-size: large">
|
<div style="font-size: large">
|
||||||
{% if recipe.instructions %}
|
{% for s in recipe.steps.all %}
|
||||||
{{ recipe.instructions | markdown | safe }}
|
{% if s.instruction %}
|
||||||
{% endif %}
|
{{ s.instruction | markdown | safe }}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if recipe.storage %}
|
{% if recipe.storage %}
|
||||||
|
Reference in New Issue
Block a user