Commit 428c391f by Kálmán Viktor

acl: disregard superuser in get objects with lvl

parent 451790d6
......@@ -177,12 +177,13 @@ class AclBase(Model):
def get_objects_with_level(cls, level, user,
group_also=True, owner_also=False):
group_also=True, owner_also=False,
logger.debug('%s.get_objects_with_level(%s,%s) called',
unicode(cls), unicode(level), unicode(user))
if user is None or not user.is_authenticated():
return cls.objects.none()
if getattr(user, 'is_superuser', False):
if getattr(user, 'is_superuser', False) and not disregard_superuser:
logger.debug('- superuser granted')
return cls.objects
if isinstance(level, basestring):
......@@ -90,7 +90,7 @@ class IndexView(LoginRequiredMixin, TemplateView):
# instances
favs = Instance.objects.filter(favourite__user=self.request.user)
instances = Instance.get_objects_with_level(
'user', user).filter(destroyed_at=None)
'user', user, disregard_superuser=True).filter(destroyed_at=None)
display = list(favs) + list(set(instances) - set(favs))
for d in display:
d.fav = True if d in favs else False
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment