several shopping list improvements

This commit is contained in:
vabene1111
2021-03-17 23:28:28 +01:00
parent 76eeed1a77
commit 2149f4034b
2 changed files with 9 additions and 7 deletions

View File

@@ -510,14 +510,14 @@ class ShoppingListRecipe(models.Model, PermissionModelMixin):
recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE, null=True, blank=True)
servings = models.DecimalField(default=1, max_digits=8, decimal_places=4)
objects = ScopedManager(space='shoppinglist__space')
objects = ScopedManager(space='recipe__space')
@staticmethod
def get_space_key():
return 'shoppinglist', 'space'
return 'recipe', 'space'
def get_space(self):
return self.shoppinglist_set.first().space
return self.recipe.space
def __str__(self):
return f'Shopping list recipe {self.id} - {self.recipe}'