diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-01-29 17:41:48 +0100 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-07-01 18:02:28 +0200 |
| commit | 75387c3c62f8623dfbcc8019c14e68de1391b0c3 (patch) | |
| tree | cd63cc6c0ed2e4d907c0026ea00682067064912b /ishtar_common/migrations/0042_auto_20180409_1901.py | |
| parent | 81bc316440558bf40a97f55424194f84e077f552 (diff) | |
| download | Ishtar-75387c3c62f8623dfbcc8019c14e68de1391b0c3.tar.bz2 Ishtar-75387c3c62f8623dfbcc8019c14e68de1391b0c3.zip | |
Finish migration refactoring
Diffstat (limited to 'ishtar_common/migrations/0042_auto_20180409_1901.py')
| -rw-r--r-- | ishtar_common/migrations/0042_auto_20180409_1901.py | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/ishtar_common/migrations/0042_auto_20180409_1901.py b/ishtar_common/migrations/0042_auto_20180409_1901.py deleted file mode 100644 index 0b377b9d8..000000000 --- a/ishtar_common/migrations/0042_auto_20180409_1901.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.10 on 2018-04-09 17:29 -from __future__ import unicode_literals - -from django.db import migrations - - -def initialize_profiles(apps, schema_editor): - # Migrate PersonType -> ProfileType - PersonType = apps.get_model('ishtar_common', 'PersonType') - ProfileType = apps.get_model('ishtar_common', 'ProfileType') - UserProfile = apps.get_model('ishtar_common', 'UserProfile') - Person = apps.get_model('ishtar_common', 'Person') - - # create profile types from person types - profile_types = {} - for person_type in PersonType.objects.all(): - default = { - 'label': person_type.label, - 'comment': person_type.comment, - 'available': person_type.available, - } - pt, created = ProfileType.objects.get_or_create( - txt_idx=person_type.txt_idx, defaults=default) - if created: - for gp in person_type.groups.all(): - pt.groups.add(gp) - profile_types[pt.txt_idx] = pt - - # match profile type with person types - for person in Person.objects.filter(ishtaruser__isnull=False): - # order by txt_idx in order to put administrator first - for idx, person_type in enumerate( - person.person_types.order_by('txt_idx').all()): - current = not(idx) # first is current - UserProfile.objects.create( - profile_type=profile_types[person_type.txt_idx], - person=person, - current=current - ) - - -class Migration(migrations.Migration): - - dependencies = [ - ('ishtar_common', '0041_auto_20180409_1900'), - ] - - operations = [ - migrations.RunPython(initialize_profiles), - ] |
