server/tools: fix note snapshots importing
This commit is contained in:
parent
658b95aad7
commit
1549b70ace
1 changed files with 10 additions and 1 deletions
|
@ -20,7 +20,8 @@ def read_file(path):
|
||||||
return handle.read()
|
return handle.read()
|
||||||
|
|
||||||
def translate_note_polygon(row):
|
def translate_note_polygon(row):
|
||||||
x, y, w, h = row['x'], row['y'], row['width'], row['height']
|
x, y = row['x'], row['y']
|
||||||
|
w, h = row.get('width', row.get('w')), row.get('height', row.get('h'))
|
||||||
x /= 100.0
|
x /= 100.0
|
||||||
y /= 100.0
|
y /= 100.0
|
||||||
w /= 100.0
|
w /= 100.0
|
||||||
|
@ -369,6 +370,14 @@ def import_snapshots(v1_session, v2_session):
|
||||||
del data['contentChecksum']
|
del data['contentChecksum']
|
||||||
if 'tags' in data and isinstance(data['tags'], dict):
|
if 'tags' in data and isinstance(data['tags'], dict):
|
||||||
data['tags'] = list(data['tags'].values())
|
data['tags'] = list(data['tags'].values())
|
||||||
|
if 'notes' in data:
|
||||||
|
notes = []
|
||||||
|
for note in data['notes']:
|
||||||
|
notes.append({
|
||||||
|
'polygon': translate_note_polygon(note),
|
||||||
|
'text': note['text'],
|
||||||
|
})
|
||||||
|
data['notes'] = notes
|
||||||
snapshot.resource_repr = row['primaryKey']
|
snapshot.resource_repr = row['primaryKey']
|
||||||
elif snapshot.resource_type == 'tag':
|
elif snapshot.resource_type == 'tag':
|
||||||
if 'banned' in data:
|
if 'banned' in data:
|
||||||
|
|
Loading…
Reference in a new issue