forked from 0x2620/pandora
implement isSeries, canPlayVideo, canPlayType
This commit is contained in:
parent
4812870a30
commit
77577e00c0
2 changed files with 27 additions and 2 deletions
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue