From 69cbee4bd512bbaaf601ff154fc3ccc81a75a3f6 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 10 Mar 2012 00:55:45 +0100 Subject: [PATCH] only return visible clips. fixes #625 --- pandora/clip/managers.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pandora/clip/managers.py b/pandora/clip/managers.py index 595ca828..5d5bb87c 100644 --- a/pandora/clip/managers.py +++ b/pandora/clip/managers.py @@ -201,4 +201,13 @@ class ClipManager(Manager): if 'keys' in data: for l in filter(lambda k: k in settings.CONFIG['clipLayers'], data['keys']): qs = qs.filter(**{l: True}) + #anonymous can only see public clips + if not user or user.is_anonymous(): + allowed_level = settings.CONFIG['capabilities']['canSeeItem']['guest'] + qs = qs.filter(item__level__lte=allowed_level) + #users can see public clips, there own clips and clips of there groups + else: + allowed_level = settings.CONFIG['capabilities']['canSeeItem'][user.get_profile().get_level()] + qs = qs.filter(Q(item__level__lte=allowed_level)|Q(item__user=user)|Q(item__groups__in=user.groups.all())) + #admins can see all available clips return qs