From 38ef78b34f41338e7ea6d8912d04ed505e5f80d6 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Sat, 10 May 2014 17:00:02 +0200 Subject: History: add a creator field * automatically add creator to new created item * associated migrations * associated tests * tests --- ishtar_common/models.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ishtar_common/models.py') diff --git a/ishtar_common/models.py b/ishtar_common/models.py index a2da684c5..4f64d6f8f 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -379,11 +379,16 @@ class HistoryError(Exception): class BaseHistorizedItem(models.Model): history_modifier = models.ForeignKey(User, related_name='+', verbose_name=_(u"Last editor")) + history_creator = models.ForeignKey(User, related_name='+', + verbose_name=_(u"Creator"), blank=True, + null=True) class Meta: abstract = True def save(self, *args, **kwargs): assert hasattr(self, 'history_modifier') == True + if not self.id: + self.history_creator = self.history_modifier super(BaseHistorizedItem, self).save(*args, **kwargs) return True -- cgit v1.2.3