Allow mealplan items to have no recipes

And display first line of notes in plan
This commit is contained in:
tourn
2020-04-13 19:56:00 +02:00
parent 83b5b6695c
commit 08cccfa133
3 changed files with 30 additions and 2 deletions

View File

@ -201,10 +201,16 @@ class MealPlan(models.Model):
MEAL_TYPES = ((BREAKFAST, _('Breakfast')), (LUNCH, _('Lunch')), (DINNER, _('Dinner')), (OTHER, _('Other')),)
user = models.ForeignKey(User, on_delete=models.CASCADE)
recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE)
recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE, blank=True, null=True)
meal = models.CharField(choices=MEAL_TYPES, max_length=128, default=BREAKFAST)
note = models.TextField(blank=True)
date = models.DateField()
def note_head(self):
try:
return self.note.split('\n')[0]
except:
return ''
def __str__(self):
return self.meal + ' (' + str(self.date) + ') ' + str(self.recipe)