Skip to content

Commit

Permalink
[Fixes #7882] Error in handling favorite (#7883)
Browse files Browse the repository at this point in the history
  • Loading branch information
etj authored Jul 28, 2021
1 parent 4160639 commit 8aa267b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion geonode/base/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#########################################################################
from urllib.parse import urljoin

from django.conf import settings
from django.contrib.auth.models import Group
from django.contrib.auth import get_user_model

Expand Down Expand Up @@ -338,7 +339,7 @@ def to_representation(self, instance):
data['perms'] = instance.get_user_perms(request.user).union(
instance.get_self_resource().get_user_perms(request.user)
)
if not request.user.is_anonymous:
if not request.user.is_anonymous and getattr(settings, "FAVORITE_ENABLED", False):
favorite = Favorite.objects.filter(user=request.user, object_id=instance.pk).count()
data['favorite'] = favorite > 0
return data
Expand Down

0 comments on commit 8aa267b

Please sign in to comment.