Skip to content
Snippets Groups Projects
Commit f43c2358 authored by Erwan Rouchet's avatar Erwan Rouchet
Browse files

Fix the fixed migration

parent a9a80c1e
No related branches found
No related tags found
1 merge request!18Transcription search
......@@ -9,15 +9,15 @@ def transcription_to_document(apps, schema_editor):
Transcription = apps.get_model('documents', 'Transcription')
nb = Transcription.objects.all().count()
last = 0
for i,ts in enumerate(Transcription.objects.all()):
percent = int(100.0 * (i+1) / nb)
for i, ts in enumerate(Transcription.objects.all()):
percent = int(100.0 * (i + 1) / nb)
if percent % 5 == 0 and last != percent:
print(' > {}% => {} / {}'.format(percent, i, nb))
last = percent
new_ts = Transcription(line=ts.line, score=ts.score, text=ts.text)
new_ts.document_ptr = Document.objects.create(type=DocumentType.Transcription, name="Transcription '{}'".format(ts.text))
new_ts.save()
new_ts.document_ptr.zones.add(ts.zone)
doc = Document.objects.create(type=DocumentType.Transcription, name="Transcription '{}'".format(ts.text))
doc.zones.add(ts.zone)
ts.document_ptr_id = doc.id
ts.save()
class Migration(migrations.Migration):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment