use isSubtitles itemKey for subtitles
This commit is contained in:
parent
20c5186640
commit
ba3d1538f4
2 changed files with 8 additions and 4 deletions
|
@ -1249,10 +1249,11 @@ class Item(models.Model):
|
||||||
return icon
|
return icon
|
||||||
|
|
||||||
def load_subtitles(self):
|
def load_subtitles(self):
|
||||||
if not utils.get_by_id(settings.CONFIG['layers'], 'subtitles'):
|
subtitles = utils.get_by_key(settings.CONFIG['layers'], 'isSubtitles', True)
|
||||||
|
if not subtitles:
|
||||||
return False
|
return False
|
||||||
with transaction.commit_on_success():
|
with transaction.commit_on_success():
|
||||||
layer = 'subtitles'
|
layer = subtitles['id']
|
||||||
Annotation.objects.filter(layer=layer,item=self).delete()
|
Annotation.objects.filter(layer=layer,item=self).delete()
|
||||||
offset = 0
|
offset = 0
|
||||||
language = ''
|
language = ''
|
||||||
|
|
|
@ -70,6 +70,9 @@ def get_positions(ids, pos):
|
||||||
pass
|
pass
|
||||||
return positions
|
return positions
|
||||||
|
|
||||||
def get_by_id(objects, id):
|
def get_by_key(objects, key, value):
|
||||||
obj = filter(lambda o: o['id'] == id, objects)
|
obj = filter(lambda o: o.get(key) == value, objects)
|
||||||
return obj and obj[0] or None
|
return obj and obj[0] or None
|
||||||
|
|
||||||
|
def get_by_id(objects, id):
|
||||||
|
return get_by_key(objects, 'id', id)
|
||||||
|
|
Loading…
Reference in a new issue