Add empty object_list support to the 'filter_objects_by_access' manager method

This commit is contained in:
Roberto Rosario
2012-01-03 02:26:29 -04:00
parent ae512a79f8
commit 43c52d64e7

View File

@@ -274,6 +274,14 @@ class AccessEntryManager(models.Manager):
if actor.is_superuser or actor.is_staff:
return object_list
try:
if object_list.count() == 0:
return object_list
except TypeError:
# object_list is not a queryset
if len(object_list) == 0:
return object_list
try:
# Try to process as a QuerySet
qs = object_list.filter(pk__in=[obj.pk for obj in self.get_allowed_class_objects(permission, actor, object_list[0])])