summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@peacefrogs.net>2014-01-13 11:05:15 +0100
committerÉtienne Loks <etienne.loks@peacefrogs.net>2014-01-13 11:05:15 +0100
commit819a2efeff00d8f09712938b7d2b6110cb7f24aa (patch)
treedba40d381f2786606febe74fa6150c94e9526c81 /ishtar_common
parent35bfe86349be3c468b0c7cdece491491ada8dcae (diff)
downloadIshtar-819a2efeff00d8f09712938b7d2b6110cb7f24aa.tar.bz2
Ishtar-819a2efeff00d8f09712938b7d2b6110cb7f24aa.zip
Add created by to record cart (refs #1590)
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/models.py19
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