From d0cfcf678c10e6a1b89a2b0864d695acf89b54e1 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 25 May 2018 12:15:03 +0200 Subject: Fix profile migration (alays create a current) --- ishtar_common/migrations/0042_auto_20180409_1901.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ishtar_common/migrations') 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, -- cgit v1.2.3