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 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import json
|
||||||
import re
|
import re
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
|
||||||
|
|
@ -138,7 +139,13 @@ class Annotation(models.Model):
|
||||||
set_public_id = not self.id or not self.public_id
|
set_public_id = not self.id or not self.public_id
|
||||||
layer = self.get_layer()
|
layer = self.get_layer()
|
||||||
if self.value:
|
if self.value:
|
||||||
self.value = utils.cleanup_value(self.value, layer['type'])
|
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
|
findvalue = self.value
|
||||||
try:
|
try:
|
||||||
|
|
@ -393,7 +400,11 @@ class Annotation(models.Model):
|
||||||
# them specially. See Item.add_empty_clips
|
# them specially. See Item.add_empty_clips
|
||||||
if l.get('isSubtitles') and 'id' in j and not self.value:
|
if l.get('isSubtitles') and 'id' in j and not self.value:
|
||||||
del j['id']
|
del j['id']
|
||||||
|
if l['type'] == "data" and "value" in j:
|
||||||
|
try:
|
||||||
|
j["value"] = json.loads(j["value"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
return j
|
return j
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue