Shorten "last update" info in details from fleet
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Sat, 20 Nov 2010 10:31:08 +0000 (10:31 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Sat, 20 Nov 2010 10:31:08 +0000 (10:31 +0000)
bin/common.py
html_templates/fleet_vessels.html

index fcfccddd30ffd96cda35db54fcdfd617b81b0f95..962f1e51256fc99f9a7e696c8d3933f7bad2e566 100755 (executable)
@@ -1210,6 +1210,17 @@ class Nmea(Nmea1, Nmea5):
         else:
             return self.timestamp_5
 
+    def get_last_updated_delta_str(self):
+        """
+        Returns a pretty formated update data as a string
+        """
+        lastupdate = self.get_last_timestamp()
+        if lastupdate == 0:
+            return u'Never'
+        dt_lastupdate = datetime.utcfromtimestamp(lastupdate)
+        delta = datetime.utcnow() - dt_lastupdate
+        return nice_timedelta_str(delta) + u' ago'
+
     def get_last_updated_str(self):
         """
         Returns a pretty formated update data as a string
index 817cc78ccebd99e3b820113b130726ec889d54c1..1d222add88b79dc01dd6dd92fdfedd6c7149353a 100644 (file)
@@ -26,7 +26,7 @@
   <td>{{ vessel.imo|default_if_none:""}}
   <td>{{ nmea.get_callsign }}
   <td>{{ nmea.get_shiptype }}
-  <td>{{ nmea.get_last_updated_str }}
+  <td>{{ nmea.get_last_updated_delta_str }}
 {% endwith %}
 {% endfor %}
 </table>