Skip to content

Commit

Permalink
[Fixes GeoNode#7882] Error in handling favorite (GeoNode#7883)
Browse files Browse the repository at this point in the history
(cherry picked from commit 8aa267b)
(cherry picked from commit 94a11e0)
  • Loading branch information
etj authored and afabiani committed Jul 29, 2021
1 parent 89a1138 commit d605bcd
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 @@
import json
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
from django.forms.models import model_to_dict
Expand Down Expand Up @@ -375,7 +376,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
# Adding links to resource_base api
Expand Down

0 comments on commit d605bcd

Please sign in to comment.