Skip to content

Commit

Permalink
review-fix-2. stylefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Resistor-git committed Sep 26, 2023
1 parent db1b329 commit 01e7d0f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions backend/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ def get_is_subscribed(self, obj):
Anonymous user can not subscribe, so func returns False in this case.
"""
current_user = self.context.get('request').user
return current_user.is_authenticated and obj.following.filter(user=current_user).exists()
return (
current_user.is_authenticated
and obj.following.filter(user=current_user).exists()
)

class Meta:
model = User
Expand Down Expand Up @@ -236,7 +239,10 @@ def get_is_favorited(self, obj):
so func returns False in this case.
"""
current_user = self.context.get('request').user
return current_user.is_authenticated and obj.favorites.filter(user=current_user).exists()
return (
current_user.is_authenticated
and obj.favorites.filter(user=current_user).exists()
)

def get_is_in_shopping_cart(self, obj):
"""
Expand All @@ -246,7 +252,8 @@ def get_is_in_shopping_cart(self, obj):
so func returns False in this case.
"""
current_user = self.context.get('request').user
return current_user.is_authenticated and obj.carts.filter(user=current_user).exists()
return (current_user.is_authenticated
and obj.carts.filter(user=current_user).exists())

class Meta:
model = Recipe
Expand Down

0 comments on commit 01e7d0f

Please sign in to comment.