mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
lots of shopping list improvements
This commit is contained in:
@@ -1184,7 +1184,6 @@ class ShoppingListRecipeSerializer(serializers.ModelSerializer):
|
||||
servings = CustomDecimalField()
|
||||
|
||||
def update(self, instance, validated_data):
|
||||
# TODO remove once old shopping list
|
||||
if 'servings' in validated_data and self.context.get('view', None).__class__.__name__ != 'ShoppingListViewSet':
|
||||
SLR = RecipeShoppingEditor(user=self.context['request'].user, space=self.context['request'].space)
|
||||
SLR.edit_servings(servings=validated_data['servings'], id=instance.id)
|
||||
@@ -1274,6 +1273,7 @@ class ShoppingListEntrySimpleCreateSerializer(serializers.Serializer):
|
||||
amount = CustomDecimalField()
|
||||
unit_id = serializers.IntegerField(allow_null=True)
|
||||
food_id = serializers.IntegerField(allow_null=True)
|
||||
ingredient_id = serializers.IntegerField(allow_null=True)
|
||||
|
||||
|
||||
class ShoppingListEntryBulkCreateSerializer(serializers.Serializer):
|
||||
|
||||
@@ -1375,7 +1375,7 @@ class ShoppingListRecipeViewSet(LoggingMixin, viewsets.ModelViewSet):
|
||||
pagination_class = DefaultPagination
|
||||
|
||||
def get_queryset(self):
|
||||
self.queryset = self.queryset.filter(Q(entries__space=self.request.space) | Q(recipe__space=self.request.space))
|
||||
self.queryset = self.queryset.filter(Q(entries__space=self.request.space) | Q(recipe__space=self.request.space) | Q(mealplan__space=self.request.space))
|
||||
|
||||
# TODO implement test for this
|
||||
if not self.detail:
|
||||
@@ -1405,6 +1405,7 @@ class ShoppingListRecipeViewSet(LoggingMixin, viewsets.ModelViewSet):
|
||||
amount=e['amount'],
|
||||
unit_id=e['unit_id'],
|
||||
food_id=e['food_id'],
|
||||
ingredient_id=e['ingredient_id'],
|
||||
created_by_id=request.user.id,
|
||||
space_id=request.space.id,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user