diff options
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/models.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index b7553d911..811e2e63b 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -440,6 +440,17 @@ class BaseHistorizedItem(models.Model): except IndexError: return + @property + def created_by(self): + q = self.history.order_by('history_date') + if not q.count(): + return + try: + modifier = IshtarUser.objects.get(pk=q.all()[0].history_modifier_id) + return modifier.person + except IshtarUser.DoesNotExist: + return + def rollback(self, date): """ Rollback to a previous state @@ -767,8 +778,10 @@ class Person(Address, OwnPerms, ValueGetter) : def __unicode__(self): values = [unicode(getattr(self, attr)) - for attr in ('surname', 'name', 'attached_to') + for attr in ('surname', 'name') if getattr(self, attr)] + if self.attached_to: + values.append(u"- " + unicode(self.attached_to)) return u" ".join(values) def get_values(self, prefix=''): @@ -806,8 +819,10 @@ class Person(Address, OwnPerms, ValueGetter) : if self.title: values = [unicode(_(self.title))] values += [unicode(getattr(self, attr)) - for attr in ('surname', 'name', 'attached_to') + for attr in ('surname', 'name') if getattr(self, attr)] + if self.attached_to: + values.append(u"- " + unicode(self.attached_to)) return u" ".join(values) @property |