avoid overlapping annotations

This commit is contained in:
j 2013-03-06 14:19:13 +00:00
parent be717933e4
commit 5ec09e804d

View File

@ -34,6 +34,9 @@ class Command(BaseCommand):
annotations = ox.srt.load(filename) annotations = ox.srt.load(filename)
print 'importing %d annotations into %s/%s' % (len(annotations), itemId, layer_id) print 'importing %d annotations into %s/%s' % (len(annotations), itemId, layer_id)
for i in range(len(annotations)-1):
if annotations[i]['out'] == annotations[i+1]['in']:
annotations[i]['out'] = annotations[i]['out'] - 0.001
with transaction.commit_on_success(): with transaction.commit_on_success():
for a in annotations: for a in annotations:
if a['value']: if a['value']:
@ -41,7 +44,8 @@ class Command(BaseCommand):
item=item, item=item,
layer=layer_id, layer=layer_id,
user=user, user=user,
start=float(a['in']), end=float(a['out']), start=float(a['in']),
end=float(a['out']),
value=a['value']) value=a['value'])
annotation.save() annotation.save()
#update facets if needed #update facets if needed