From c400b561debc24711d48b14fedbc5d610cd1ced5 Mon Sep 17 00:00:00 2001 From: Sanj Date: Wed, 23 May 2012 16:48:40 +0530 Subject: [PATCH] backend functions for queries + templates for area, route, stop --- chaloBEST/mumbai/models.py | 8 ++++++++ chaloBEST/templates/area.html | 15 ++++++++++++++- chaloBEST/templates/base.html | 19 ++++++++++++++++++ chaloBEST/templates/route.html | 35 ++++++++++++++++++++++------------ 4 files changed, 64 insertions(+), 13 deletions(-) diff --git a/chaloBEST/mumbai/models.py b/chaloBEST/mumbai/models.py index 3086d9c..fab1873 100644 --- a/chaloBEST/mumbai/models.py +++ b/chaloBEST/mumbai/models.py @@ -214,6 +214,11 @@ class Stop(models.Model): tup = (self.point, dist,) return Stop.objects.filter(point__distance_lte=tup) + @property + def routes(self): + return Route.objects.filter(routedetail__stop=self) + + def __unicode__(self): return self.name @@ -263,6 +268,9 @@ class Route(models.Model): 'url': self.get_absolute_url() } + def areas_passed(self): + return Area.objects.filter(stop__routedetail__route=self).distinct() + class RouteDetail(models.Model): route_code = models.TextField() route = models.ForeignKey(Route, to_field="code", null=True, blank=True) diff --git a/chaloBEST/templates/area.html b/chaloBEST/templates/area.html index d80afce..f8cd19d 100644 --- a/chaloBEST/templates/area.html +++ b/chaloBEST/templates/area.html @@ -21,10 +21,11 @@ a:hover { {% block body %}
+ @@ -40,6 +41,18 @@ a:hover { {% endfor %}
+
+ + +
+
{% endblock %} diff --git a/chaloBEST/templates/base.html b/chaloBEST/templates/base.html index 2fa39ea..ad9c387 100644 --- a/chaloBEST/templates/base.html +++ b/chaloBEST/templates/base.html @@ -7,6 +7,25 @@ console.firebug=true;//fix the openlayer problem + ChaloBEST: {% block title %} {% endblock %} {% block head %} diff --git a/chaloBEST/templates/route.html b/chaloBEST/templates/route.html index 82132ae..06d80b4 100644 --- a/chaloBEST/templates/route.html +++ b/chaloBEST/templates/route.html @@ -105,17 +105,28 @@ function onFeatureUnselect(obj) { {% endblock %} {% block body %} - - -
- +
+ +
+ +
+ +
    + {% for area in route.areas_passed %} +
  • + {{ area.name }} +
  • + {% endfor %} + +
+
+ +
{% endblock %}