summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-04-09 19:06:10 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-06-12 08:39:42 +0200
commit7f5a100fd07af4b8be51f524b81ae9d8776ca9b0 (patch)
treed580da3cf240f3d1b8e2be5fd1ad6b93a997133d /ishtar_common
parent4d31ec2ef6d89e645f93285e382ea8176c7cd90b (diff)
downloadIshtar-7f5a100fd07af4b8be51f524b81ae9d8776ca9b0.tar.bz2
Ishtar-7f5a100fd07af4b8be51f524b81ae9d8776ca9b0.zip
Profile: default->current
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/migrations/0040_auto_20180409_1900.py (renamed from ishtar_common/migrations/0040_auto_20180409_1821.py)4
-rw-r--r--ishtar_common/migrations/0041_auto_20180409_1901.py (renamed from ishtar_common/migrations/0041_auto_20180409_1759.py)8
-rw-r--r--ishtar_common/models.py13
3 files changed, 11 insertions, 14 deletions
diff --git a/ishtar_common/migrations/0040_auto_20180409_1821.py b/ishtar_common/migrations/0040_auto_20180409_1900.py
index bdf27cfc2..a8cf51e33 100644
--- a/ishtar_common/migrations/0040_auto_20180409_1821.py
+++ b/ishtar_common/migrations/0040_auto_20180409_1900.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Generated by Django 1.11.10 on 2018-04-09 18:21
+# Generated by Django 1.11.10 on 2018-04-09 19:00
from __future__ import unicode_literals
import django.core.validators
@@ -38,7 +38,7 @@ class Migration(migrations.Migration):
name='UserProfile',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
- ('default', models.BooleanField(default=False, verbose_name='Default profile')),
+ ('current', models.BooleanField(default=False, verbose_name='Current profile')),
('person', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='profiles', to='ishtar_common.Person', verbose_name='Person')),
('profile_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.ProfileType', verbose_name='Profile type')),
],
diff --git a/ishtar_common/migrations/0041_auto_20180409_1759.py b/ishtar_common/migrations/0041_auto_20180409_1901.py
index 2ea56823a..cc34bb91c 100644
--- a/ishtar_common/migrations/0041_auto_20180409_1759.py
+++ b/ishtar_common/migrations/0041_auto_20180409_1901.py
@@ -29,21 +29,21 @@ def initialize_profiles(apps, schema_editor):
# match profile type with person types
for person in Person.objects.filter(ishtaruser__isnull=False):
- # is default if only one person_type is concerned
- default = person.person_types.count() == 1
+ # 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():
UserProfile.objects.create(
profile_type=profile_types[person_type.txt_idx],
person=person,
- default=default
+ current=current
)
class Migration(migrations.Migration):
dependencies = [
- ('ishtar_common', '0040_auto_20180409_1821'),
+ ('ishtar_common', '0040_auto_20180409_1900'),
]
operations = [
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 7c2069309..9aaf7bab1 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -2471,20 +2471,17 @@ class Person(Address, Merge, OwnPerms, ValueGetter):
for attr in ['title', 'salutation'] if getattr(self, attr)])
@property
- def default_profile(self):
- q = self.profiles.filter(default=True)
+ def current_profile(self):
+ q = self.profiles.filter(current=True)
if q.count():
return q.all()[0]
q = self.profiles
nb = q.count()
if not nb:
return
- if nb > 1:
- # arbitrary return the first one
- return q.all()[0]
- # if there is only one it is the default
+ # arbitrary set the first one as the current
profile = q.all()[0]
- profile.default = True
+ profile.current = True
profile.save()
return profile
@@ -2665,7 +2662,7 @@ post_delete.connect(post_save_cache, sender=ProfileType)
class UserProfile(models.Model):
profile_type = models.ForeignKey(
ProfileType, verbose_name=_(u"Profile type"))
- default = models.BooleanField(_(u"Default profile"), default=False)
+ current = models.BooleanField(_(u"Current profile"), default=False)
person = models.ForeignKey(
Person, verbose_name=_(u"Person"), related_name='profiles')