add support for data annotations
This commit is contained in:
parent
e8f0f0262c
commit
ea322a054e
1 changed files with 13 additions and 2 deletions
|
|
@ -1,5 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import json
|
||||
import re
|
||||
import unicodedata
|
||||
|
||||
|
|
@ -138,6 +139,12 @@ class Annotation(models.Model):
|
|||
set_public_id = not self.id or not self.public_id
|
||||
layer = self.get_layer()
|
||||
if self.value:
|
||||
if layer['type'] == "data" and not isinstance(self.value, str):
|
||||
try:
|
||||
self.value = json.dumps(self.value, ensure_ascii=False)
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
self.value = utils.cleanup_value(self.value, layer['type'])
|
||||
|
||||
findvalue = self.value
|
||||
|
|
@ -393,7 +400,11 @@ class Annotation(models.Model):
|
|||
# them specially. See Item.add_empty_clips
|
||||
if l.get('isSubtitles') and 'id' in j and not self.value:
|
||||
del j['id']
|
||||
|
||||
if l['type'] == "data" and "value" in j:
|
||||
try:
|
||||
j["value"] = json.loads(j["value"])
|
||||
except:
|
||||
pass
|
||||
return j
|
||||
|
||||
def __str__(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue