backend functions for queries + templates for area, route, stop
This commit is contained in:
parent
ddfeee1226
commit
c400b561de
|
@ -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)
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -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 %}
|
||||
|
||||
|
|
|
@ -105,17 +105,28 @@ function onFeatureUnselect(obj) {
|
|||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<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>
|
||||
</li>
|
||||
|
||||
{% endfor %}
|
||||
|
||||
</ul>
|
||||
|
||||
<div id="map">
|
||||
|
||||
<div id="stopListWrapper">
|
||||
<input class="listFilterInput" placeholder="Filter..." />
|
||||
<ul id="stopList">
|
||||
{% for r in routeDetails %}
|
||||
<li>
|
||||
<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>
|
||||
|
||||
<div id="map"></div>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in New Issue
Block a user