diff --git a/pandora/item/managers.py b/pandora/item/managers.py index f781b5f0a..626617079 100644 --- a/pandora/item/managers.py +++ b/pandora/item/managers.py @@ -62,12 +62,29 @@ def parseCondition(condition, user): 'year': 'string', 'length': 'string', 'list': 'list', - 'layer': 'string' + 'layer': 'string', }.get(key_type, key_type) if k == 'list': key_type = 'list' + if k in ('isSeries', ): + key_type = 'bool' - if key_type == "string": + if k in ('canPlayVideo', 'canPlayClips'): + level = user.is_anonymous() and 'guest' or user.get_profile().get_level() + allowed_level = settings.CONFIG['capabilities'][k][level] + if v: + q = Q(level__lte=allowed_level) + else: + q = Q(level__gt=allowed_level) + if exclude: + q = ~q + return q + elif key_type == 'bool': + q = Q(**{'find__key': k, 'find__value': v and '1' or '0'}) + if exclude: + q = ~q + return q + elif key_type == "string": in_find = not k.startswith('itemId') if in_find: value_key = 'find__value' diff --git a/pandora/item/models.py b/pandora/item/models.py index e1f41306c..46250eaa2 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -513,6 +513,8 @@ class Item(models.Model): def save(key, value): if value not in ('', None): f, created = ItemFind.objects.get_or_create(item=self, key=key) + if isinstance(value, bool): + value = value and '1' or '0' if isinstance(value, basestring): value = value.strip() f.value = value @@ -561,6 +563,12 @@ class Item(models.Model): else: save(key, values) + isSeries = self.get('series', + self.get('episodeTitle', + self.get('episode', + self.get('seriesTitle')))) != None + save('isSeries', isSeries) + def update_sort(self): try: s = self.sort