@@ -0,0 +1,1244 @@
+# -*- coding: utf-8 -*-%0A# Manually written%0Afrom __future__ import unicode_literals%0A%0Afrom django.db import migrations, models%0A%0Aimport datetime%0Aimport dateutil%0A%0A%0Adef create_time_entries(apps, schema_editor):%0A    TaskAssignment = apps.get_model('orchestra', 'TaskAssignment')%0A    TimeEntry = apps.get_model('orchestra', 'TimeEntry')%0A%0A    for assignment in TaskAssignment.objects.all():%0A        # Check if keys exist before processing, to be compatible with previous%0A        # versions of snapshots.%0A        if 'snapshots' not in assignment.snapshots:%0A            continue%0A        for snapshot in assignment.snapshots%5B'snapshots'%5D:%0A            if 'datetime' not in snapshot or 'work_time_seconds' not in snapshot:%0A                continue%0A            date = dateutil.parser.parse(snapshot%5B'datetime'%5D).date()%0A            time_worked = datetime.timedelta(seconds=snapshot%5B'work_time_seconds'%5D)%0A            TimeEntry.objects.get_or_create(assignment=assignment, date=date,%0A                                            time_worked=time_worked)%0A%0A%0Aclass Migration(migrations.Migration):%0A%0A    dependencies = %5B%0A        ('orchestra', '0026_timeentry'),%0A    %5D%0A%0A    operations = %5B%0A        migrations.RunPython(create_time_entries),  # manually-reviewed%0A    %5D%0A

Migrate task assignment snapshots to TimeEntry