From 5df7943ca24d893a3db02a1d12f494acf8dd549b Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 9 Apr 2018 20:22:12 +0200 Subject: Add a profile page to manage preferences (refs #4046) --- ishtar_common/models.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'ishtar_common/models.py') diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 9aaf7bab1..a6fc8722d 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2670,6 +2670,9 @@ class UserProfile(models.Model): verbose_name = _(u"User profile") verbose_name_plural = _(u"User profiles") + def __unicode__(self): + return unicode(self.profile_type) + class IshtarUser(FullSearch): TABLE_COLS = ('username', 'person__name', 'person__surname', @@ -2706,6 +2709,17 @@ class IshtarUser(FullSearch): def __unicode__(self): return unicode(self.person) + @property + def current_profile_name(self): + q = UserProfile.objects.filter(current=True, person__ishtaruser=self) + if q.count(): + return q.values('profile_type__label').all()[0][ + 'profile_type__label'] + profile = self.person.current_profile + if not profile: + return u"" + return unicode(profile) + @classmethod def set_superuser(cls, user): q = cls.objects.filter(user_ptr=user) -- cgit v1.2.3