From 7b42ba9df55362b7e095f97c1a9de6e8bf4fe228 Mon Sep 17 00:00:00 2001 From: Johan Lundberg Date: Thu, 20 Mar 2014 14:01:49 +0100 Subject: Fixed a Python 2.7 only attribute for timedelta. --- meetingtools/apps/stats/models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'meetingtools/apps/stats') diff --git a/meetingtools/apps/stats/models.py b/meetingtools/apps/stats/models.py index 495bd65..39e7bbb 100644 --- a/meetingtools/apps/stats/models.py +++ b/meetingtools/apps/stats/models.py @@ -21,7 +21,12 @@ class UserMeetingTransaction(models.Model): def seconds(self): delta = self.date_closed - self.date_created - return delta.total_seconds() + if hasattr(delta, 'total_seconds'): + # Python 2.7 + return delta.total_seconds() + else: + # Python 2.6 + return (delta.microseconds + (delta.seconds + delta.days * 24 * 3600) * 10 ** 6) / 10 ** 6 def __unicode__(self): return "(%d) %d seconds in %s" % (self.txid,self.seconds(),self.sco) -- cgit v1.1