code: def has_permission_to_view(page, user):
      
      if page.permissions.count() == 0:
          return True
      for perm in page.permissions.all():
          perm_label = '%s.%s' % (perm.content_type.app_label, perm.codename)
          if user.has_perm(perm_label):
              return True
      return False
docs: Check whether the user has permission to view the page. If the user has
      any of the page's permissions, they have permission. If the page has no set
      permissions, they have permission.