Allow mealplan items to have no recipes
And display first line of notes in plan
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user