Skip to content

Commit

Permalink
[Fixes #9901] Infinite loading if no resource with "view permissions"…
Browse files Browse the repository at this point in the history
… is avaialble (#9905)
  • Loading branch information
mattiagiupponi committed Aug 24, 2022
1 parent cd64cbf commit c3d3eb6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions geonode/base/api/permissions.py
Expand Up @@ -17,6 +17,7 @@
#
#########################################################################
import logging
from django.conf import settings
from django.contrib.auth import get_user_model

from rest_framework import permissions
Expand All @@ -25,7 +26,8 @@

from geonode.security.utils import (
get_users_with_perms,
get_resources_with_perms)
get_resources_with_perms,
get_visible_resources)
from geonode.groups.models import GroupProfile
from rest_framework.permissions import DjangoModelPermissions
from rest_framework.exceptions import NotFound
Expand Down Expand Up @@ -254,7 +256,12 @@ def has_permission(self, request, view):
# if at least one of the permissions is available the request is True
return any([_perm in available_perms for _perm in perms_without_base])

if not ResourceBase.objects.exists():
if not get_visible_resources(
queryset,
request.user if request else None,
admin_approval_required=settings.ADMIN_MODERATE_UPLOADS,
unpublished_not_visible=settings.RESOURCE_PUBLISHING,
private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES):
# there are not resource in the db, needed usually for fresh installations
return request.method in permissions.SAFE_METHODS
# check if the user have one of the perms in all the resource available
Expand Down

0 comments on commit c3d3eb6

Please sign in to comment.