def accessible_to(self, user):
        """
        returns all the items that are accessible to the specified user
        if user is not authenticated will return public items
        
        :param user: an user instance
        """
        if user.is_superuser:
            try:
                queryset = self.get_queryset()
            except AttributeError:
                queryset = self
        elif user.is_authenticated():
            # get user group (higher id)
            group = user.groups.all().order_by('-id')[0]
            queryset = self.filter(access_level__lte=ACCESS_LEVELS.get(group.name))
        else:
            queryset = self.filter(access_level__lte=ACCESS_LEVELS.get('public'))
        return queryset
def accessible_to ( self , user ) : if user . is_superuser : try : queryset = self . get_queryset ( ) except AttributeError : queryset = self elif user . is_authenticated ( ) : group = user . groups . all ( ) . order_by ( '-id' ) [ 0 ] queryset = self . filter ( access_level__lte = ACCESS_LEVELS . get ( group . name ) ) else : queryset = self . filter ( access_level__lte = ACCESS_LEVELS . get ( 'public' ) ) return queryset
returns all the items that are accessible to the specified user
        if user is not authenticated will return public items
        
        :param user: an user instance