diff --git a/observations/models.py b/observations/models.py index 5969a74..b5d936a 100644 --- a/observations/models.py +++ b/observations/models.py @@ -117,6 +117,15 @@ def _observed_as_string(self): return ", ".join([ test.parameter.name for test in self.parameters.all()]) + def get_timestamp(self): + """Return the most useful timestamp.""" + return self.reference_timestamp or self.created_timestamp + + def get_location(self): + """Return a nice location name.""" + return self.location_reference or "{0:0.2f}, {1:0.2f}".format( + self.location.x, self.location.y) + class TestValue(models.Model): """A Test, as measured during a Measurement, resulting in a Value.""" diff --git a/openwater/templates/home.html b/openwater/templates/home.html index d5bfc19..be8baa4 100644 --- a/openwater/templates/home.html +++ b/openwater/templates/home.html @@ -66,6 +66,16 @@
{{ entry.title }}
+
+

Latest measurements

+ +
Tweets
diff --git a/openwater/views.py b/openwater/views.py index d630e30..3fa285f 100644 --- a/openwater/views.py +++ b/openwater/views.py @@ -4,6 +4,7 @@ from django.views.generic.base import TemplateView from diario.models import Entry +from observations.models import Measurement class HomePageView(TemplateView): @@ -13,4 +14,5 @@ class HomePageView(TemplateView): def get_context_data(self, **kwargs): context = super(HomePageView, self).get_context_data(**kwargs) context['entry_list'] = Entry.objects.all()[:3] + context['measurement_list'] = Measurement.objects.order_by('-created_timestamp')[:5] return context