diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2015-01-29 00:17:28 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-01-29 00:17:28 +0100 |
commit | 61a55f5f530f5d5f974218f88015ff4c0ac191cc (patch) | |
tree | 1f19d3d7ee0032db1d391dc1888ea0efb10557df /archaeological_operations/models.py | |
parent | 999eefae2632bb01a968d088ccd6406f7b0bc896 (diff) | |
download | Ishtar-61a55f5f530f5d5f974218f88015ff4c0ac191cc.tar.bz2 Ishtar-61a55f5f530f5d5f974218f88015ff4c0ac191cc.zip |
Operation: put a default year from start_date
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r-- | archaeological_operations/models.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 5e3b05097..7d13669b1 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -416,6 +416,12 @@ class Operation(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem, return {'date':item.history_date, 'user':IshtarUser.objects.get(pk=item.history_modifier_id)} + def save(self, *args, **kwargs): + # put a default year if start_date is defined + if self.start_date and not self.year: + self.year = self.start_date.year + return super(Operation, self).save(*args, **kwargs) + m2m_changed.connect(cached_label_changed, sender=Operation.towns.through) def operation_post_save(sender, **kwargs): |