small fix in canViewList

This commit is contained in:
Pierre Brunet 2017-02-05 15:22:52 +01:00
parent fa1a4599b6
commit b3c2c79975

View File

@ -4,6 +4,7 @@ from django.shortcuts import render
from django.http import HttpResponseForbidden, HttpResponseNotFound from django.http import HttpResponseForbidden, HttpResponseNotFound
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist, ImproperlyConfigured from django.core.exceptions import PermissionDenied, ObjectDoesNotExist, ImproperlyConfigured
from django.views.generic.base import View from django.views.generic.base import View
from django.db.models import Count
from core.models import Group from core.models import Group
from core.views.forms import LoginForm from core.views.forms import LoginForm
@ -110,7 +111,7 @@ class CanViewMixin(View):
except: pass except: pass
# If we get here, it's a ListView # If we get here, it's a ListView
l_id = [o.id for o in self.get_queryset() if can_view(o, request.user)] l_id = [o.id for o in self.get_queryset() if can_view(o, request.user)]
if not l_id: if ((not l_id) and self.get_queryset().count() != 0):
raise PermissionDenied raise PermissionDenied
self._get_queryset = self.get_queryset self._get_queryset = self.get_queryset
def get_qs(self2): def get_qs(self2):