summaryrefslogtreecommitdiff
path: root/ishtar_common/migrations/0042_auto_20180409_1901.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-05-25 12:15:03 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-06-12 08:49:06 +0200
commite9cce1be89f1dfb903b08eabcc921fc6ed4d236e (patch)
treec14672a832b1ff0eceeba2353a803daa1f640f26 /ishtar_common/migrations/0042_auto_20180409_1901.py
parent10882ea43688d44ad5a5b5591e28d4936d09cd47 (diff)
downloadIshtar-e9cce1be89f1dfb903b08eabcc921fc6ed4d236e.tar.bz2
Ishtar-e9cce1be89f1dfb903b08eabcc921fc6ed4d236e.zip
Fix profile migration (alays create a current)
Diffstat (limited to 'ishtar_common/migrations/0042_auto_20180409_1901.py')
-rw-r--r--ishtar_common/migrations/0042_auto_20180409_1901.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/ishtar_common/migrations/0042_auto_20180409_1901.py b/ishtar_common/migrations/0042_auto_20180409_1901.py
index a2faa24e4..0b377b9d8 100644
--- a/ishtar_common/migrations/0042_auto_20180409_1901.py
+++ b/ishtar_common/migrations/0042_auto_20180409_1901.py
@@ -29,10 +29,10 @@ def initialize_profiles(apps, schema_editor):
# match profile type with person types
for person in Person.objects.filter(ishtaruser__isnull=False):
- # is current if only one person_type is concerned
- current = person.person_types.count() == 1
- # only person with an account are concerned
- for person_type in person.person_types.all():
+ # 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,