ordering of ingredients and steps

This commit is contained in:
vabene1111
2020-06-26 14:50:33 +02:00
parent c178aea363
commit 3d4aebcd9d
3 changed files with 86 additions and 43 deletions

View File

@ -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):