def get_is_bookmarked()

in pulseapi/entries/serializers/base.py [0:0]


    def get_is_bookmarked(self, instance):
        """
        Check whether the current user has bookmarked this
        Entry. Anonymous users always see False
        """
        user = self.context.get('user')

        if user and user.is_authenticated:
            # instance.bookmarked_by.all() is already prefetched and cached in the QuerySet
            return any(bookmark_by.profile.user == user for bookmark_by in instance.bookmarked_by.all())

        return False