forked from 0x2620/pandora
merge
This commit is contained in:
commit
f22c03bbea
2 changed files with 27 additions and 2 deletions
|
@ -62,12 +62,29 @@ def parseCondition(condition, user):
|
||||||
'year': 'string',
|
'year': 'string',
|
||||||
'length': 'string',
|
'length': 'string',
|
||||||
'list': 'list',
|
'list': 'list',
|
||||||
'layer': 'string'
|
'layer': 'string',
|
||||||
}.get(key_type, key_type)
|
}.get(key_type, key_type)
|
||||||
if k == 'list':
|
if k == 'list':
|
||||||
key_type = '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')
|
in_find = not k.startswith('itemId')
|
||||||
if in_find:
|
if in_find:
|
||||||
value_key = 'find__value'
|
value_key = 'find__value'
|
||||||
|
|
|
@ -513,6 +513,8 @@ class Item(models.Model):
|
||||||
def save(key, value):
|
def save(key, value):
|
||||||
if value not in ('', None):
|
if value not in ('', None):
|
||||||
f, created = ItemFind.objects.get_or_create(item=self, key=key)
|
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):
|
if isinstance(value, basestring):
|
||||||
value = value.strip()
|
value = value.strip()
|
||||||
f.value = value
|
f.value = value
|
||||||
|
@ -561,6 +563,12 @@ class Item(models.Model):
|
||||||
else:
|
else:
|
||||||
save(key, values)
|
save(key, values)
|
||||||
|
|
||||||
|
isSeries = self.get('series',
|
||||||
|
self.get('episodeTitle',
|
||||||
|
self.get('episode',
|
||||||
|
self.get('seriesTitle')))) != None
|
||||||
|
save('isSeries', isSeries)
|
||||||
|
|
||||||
def update_sort(self):
|
def update_sort(self):
|
||||||
try:
|
try:
|
||||||
s = self.sort
|
s = self.sort
|
||||||
|
|
Loading…
Reference in a new issue