diff options
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index d14e9b346..51d3550e9 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2997,6 +2997,8 @@ class UserProfile(models.Model): areas = models.ManyToManyField("Area", verbose_name=_(u"Areas"), blank=True, related_name='profiles') current = models.BooleanField(_(u"Current profile"), default=False) + show_field_number = models.BooleanField( + _(u"Show field number"), default=False) person = models.ForeignKey( Person, verbose_name=_(u"Person"), related_name='profiles') @@ -3062,6 +3064,16 @@ class UserProfile(models.Model): p.save() +def post_save_userprofile(sender, **kwargs): + if not kwargs.get('instance'): + return + instance = kwargs.get('instance') + instance.person.ishtaruser.show_field_number(update=True) + + +post_save.connect(post_save_userprofile, sender=UserProfile) + + class IshtarUser(FullSearch): TABLE_COLS = ('username', 'person__name', 'person__surname', 'person__email', 'person__person_types_list', @@ -3123,6 +3135,16 @@ class IshtarUser(FullSearch): def __unicode__(self): return unicode(self.person) + def show_field_number(self, update=False): + cache_key, value = get_cache(self.__class__, ['show_field_number']) + if not update and value is not None: + return value + value = False + if self.current_profile: + value = self.current_profile.show_field_number + cache.set(cache_key, value, settings.CACHE_TIMEOUT) + return value + @property def current_profile_name(self): q = UserProfile.objects.filter(current=True, person__ishtaruser=self) |