WIP
This commit is contained in:
parent
10a33add75
commit
0b1d8bbd5f
@ -488,7 +488,7 @@ class Food(ExportModelOperationsMixin('food'), TreeModel, PermissionModelMixin):
|
|||||||
description = models.TextField(default='', blank=True)
|
description = models.TextField(default='', blank=True)
|
||||||
on_hand = models.BooleanField(default=False)
|
on_hand = models.BooleanField(default=False)
|
||||||
inherit = models.BooleanField(default=False)
|
inherit = models.BooleanField(default=False)
|
||||||
ignore_inherit = models.ManyToManyField(FoodInheritField, blank=True) # is this better as inherit instead of ignore inherit? which is more intuitive?
|
ignore_inherit = models.ManyToManyField(FoodInheritField, blank=True) # is this better as inherit instead of ignore inherit? which is more intuitive?
|
||||||
|
|
||||||
space = models.ForeignKey(Space, on_delete=models.CASCADE)
|
space = models.ForeignKey(Space, on_delete=models.CASCADE)
|
||||||
objects = ScopedManager(space='space', _manager_class=TreeManager)
|
objects = ScopedManager(space='space', _manager_class=TreeManager)
|
||||||
@ -827,7 +827,7 @@ class ShoppingListRecipe(ExportModelOperationsMixin('shopping_list_recipe'), mod
|
|||||||
|
|
||||||
def get_owner(self):
|
def get_owner(self):
|
||||||
try:
|
try:
|
||||||
return self.entries.first().created_by or self.shoppinglist_set.first().created_by
|
return getattr(self.entries.first(), 'created_by', None) or getattr(self.shoppinglist_set.first(), 'created_by', None)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -365,7 +365,7 @@ class FoodSerializer(UniqueFieldsMixin, WritableNestedModelSerializer, ExtendedR
|
|||||||
supermarket_category = SupermarketCategorySerializer(allow_null=True, required=False)
|
supermarket_category = SupermarketCategorySerializer(allow_null=True, required=False)
|
||||||
recipe = RecipeSimpleSerializer(allow_null=True, required=False)
|
recipe = RecipeSimpleSerializer(allow_null=True, required=False)
|
||||||
shopping = serializers.SerializerMethodField('get_shopping_status')
|
shopping = serializers.SerializerMethodField('get_shopping_status')
|
||||||
ignore_inherit = FoodInheritFieldSerializer(many=True)
|
ignore_inherit = FoodInheritFieldSerializer(allow_null=True, many=True, required=False)
|
||||||
|
|
||||||
recipe_filter = 'steps__ingredients__food'
|
recipe_filter = 'steps__ingredients__food'
|
||||||
|
|
||||||
|
@ -5,10 +5,10 @@ import uuid
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from django.contrib import auth
|
from django.contrib import auth
|
||||||
from django.contrib.auth.models import User, Group
|
from django.contrib.auth.models import Group, User
|
||||||
from django_scopes import scopes_disabled
|
from django_scopes import scopes_disabled
|
||||||
|
|
||||||
from cookbook.models import Space, Recipe, Step, Ingredient, Food, Unit
|
from cookbook.models import Food, Ingredient, Recipe, Space, Step, Unit
|
||||||
|
|
||||||
|
|
||||||
# hack from https://github.com/raphaelm/django-scopes to disable scopes for all fixtures
|
# hack from https://github.com/raphaelm/django-scopes to disable scopes for all fixtures
|
||||||
@ -52,8 +52,8 @@ def get_random_recipe(space_1, u1_s1):
|
|||||||
internal=True,
|
internal=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
s1 = Step.objects.create(name=uuid.uuid4(), instruction=uuid.uuid4(), space=space_1, )
|
s1 = Step.objects.create(name=str(uuid.uuid4()), instruction=str(uuid.uuid4()), space=space_1, )
|
||||||
s2 = Step.objects.create(name=uuid.uuid4(), instruction=uuid.uuid4(), space=space_1, )
|
s2 = Step.objects.create(name=str(uuid.uuid4()), instruction=str(uuid.uuid4()), space=space_1, )
|
||||||
|
|
||||||
r.steps.add(s1)
|
r.steps.add(s1)
|
||||||
r.steps.add(s2)
|
r.steps.add(s2)
|
||||||
@ -63,8 +63,8 @@ def get_random_recipe(space_1, u1_s1):
|
|||||||
Ingredient.objects.create(
|
Ingredient.objects.create(
|
||||||
amount=1,
|
amount=1,
|
||||||
food=Food.objects.get_or_create(name=str(uuid.uuid4()), space=space_1)[0],
|
food=Food.objects.get_or_create(name=str(uuid.uuid4()), space=space_1)[0],
|
||||||
unit=Unit.objects.create(name=uuid.uuid4(), space=space_1, ),
|
unit=Unit.objects.create(name=str(uuid.uuid4()), space=space_1, ),
|
||||||
note=uuid.uuid4(),
|
note=str(uuid.uuid4()),
|
||||||
space=space_1,
|
space=space_1,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -73,8 +73,8 @@ def get_random_recipe(space_1, u1_s1):
|
|||||||
Ingredient.objects.create(
|
Ingredient.objects.create(
|
||||||
amount=1,
|
amount=1,
|
||||||
food=Food.objects.get_or_create(name=str(uuid.uuid4()), space=space_1)[0],
|
food=Food.objects.get_or_create(name=str(uuid.uuid4()), space=space_1)[0],
|
||||||
unit=Unit.objects.create(name=uuid.uuid4(), space=space_1, ),
|
unit=Unit.objects.create(name=str(uuid.uuid4()), space=space_1, ),
|
||||||
note=uuid.uuid4(),
|
note=str(uuid.uuid4()),
|
||||||
space=space_1,
|
space=space_1,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user