diff --git a/cookbook/migrations/0065_auto_20200626_1444.py b/cookbook/migrations/0065_auto_20200626_1444.py new file mode 100644 index 00000000..3e2c2995 --- /dev/null +++ b/cookbook/migrations/0065_auto_20200626_1444.py @@ -0,0 +1,23 @@ +# Generated by Django 3.0.7 on 2020-06-26 12:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cookbook', '0064_auto_20200625_2329'), + ] + + operations = [ + migrations.AddField( + model_name='ingredient', + name='order', + field=models.IntegerField(default=0), + ), + migrations.AddField( + model_name='step', + name='order', + field=models.IntegerField(default=0), + ), + ] diff --git a/cookbook/models.py b/cookbook/models.py index fe2d5d2d..cf95d79d 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -150,10 +150,14 @@ class Ingredient(models.Model): unit = models.ForeignKey(Unit, on_delete=models.PROTECT) amount = models.DecimalField(default=0, decimal_places=16, max_digits=32) note = models.CharField(max_length=64, null=True, blank=True) + order = models.IntegerField(default=0) def __str__(self): return str(self.amount) + ' ' + str(self.unit) + ' ' + str(self.food) + class Meta: + ordering = ['order', 'pk'] + class Step(models.Model): TEXT = 'TEXT' @@ -161,6 +165,10 @@ class Step(models.Model): kind = models.CharField(choices=((TEXT, _('Text')),), default=TEXT, max_length=16) instruction = models.TextField(blank=True) ingredients = models.ManyToManyField(Ingredient, blank=True) + order = models.IntegerField(default=0) + + class Meta: + ordering = ['order', 'pk'] class Recipe(models.Model): diff --git a/cookbook/templates/forms/edit_internal_recipe.html b/cookbook/templates/forms/edit_internal_recipe.html index 7f0397e9..7c1d6d10 100644 --- a/cookbook/templates/forms/edit_internal_recipe.html +++ b/cookbook/templates/forms/edit_internal_recipe.html @@ -13,6 +13,9 @@ + + + {% endblock %} {% block content %} @@ -20,7 +23,7 @@

{% trans 'Edit Recipe' %}

- +