backend functions for queries + templates for area, route, stop

This commit is contained in:
Sanj 2012-05-23 16:48:40 +05:30
parent ddfeee1226
commit c400b561de
4 changed files with 64 additions and 13 deletions

View File

@ -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)

View File

@ -21,10 +21,11 @@ a:hover {
{% block body %}
<div id="stopListWrapper" class="listColumn">
<input class="listFilterInput" placeholder="Filter..." />
<ul id="stopList">
{% for stop in stops %}
<li>
<a href="{{ stop.get_absolute_url }}">{{ s.name }}</a>
<a href="{{ stop.get_absolute_url }}">{{ s.display_name }}</a>
</li>
{% endfor %}
</ul>
@ -40,6 +41,18 @@ a:hover {
{% endfor %}
</ul>
</div>
<div id="areaListWrapper" class="listColumn">
<input class="listFilterInput" placeholder="Filter..." />
<ul id="areaList">
{% for area in area.nearby_areas %}
<li>
<a href="{{ area.get_absolute_url }}">{{ area.display_name }}</a>
</li>
{% endfor %}
</ul>
</div>
<div id="map"></div>
{% endblock %}

View File

@ -7,6 +7,25 @@
console.firebug=true;//fix the openlayer problem
</script>
<script type="text/javascript" src="http://openlayers.org/dev/OpenLayers.js"></script>
<style type="text/css">
body,html {
width: 100%;
}
#wrapper {
width: 100%;
}
.listColumn {
width: 15%;
float: left;
}
#map {
float: left;
width: 50%;
}
</style>
<title>ChaloBEST: {% block title %} {% endblock %}</title>
{% block head %}

View File

@ -105,17 +105,28 @@ function onFeatureUnselect(obj) {
{% endblock %}
{% block body %}
<div id="stopListWrapper">
<input class="listFilterInput" placeholder="Filter..." />
<ul id="stopList">
{% for r in routeDetails %}
<li>
<a href="{{ r.stop.get_absolute_url }}" class="{% if r.stop.point %} has_point {% else %} no_point {% endif %}">{{ r.stop.name }}</a>
<a href="{{ r.stop.get_absolute_url }}">{{ r.stop.name }}</a>
</li>
{% endfor %}
</ul>
</div>
<div id="areaListWrapper">
<input class="listFilterInput" placeholder="Filter..." />
<ul id="areaList">
{% for area in route.areas_passed %}
<li>
<a href="{{ area.get_absolute_url }}">{{ area.name }}</a>
</li>
{% endfor %}
</ul>
<div id="map">
</div>
<div id="map"></div>
{% endblock %}