use GeoManager on models to allow spatial queries

This commit is contained in:
Sanj 2012-05-23 15:33:44 +05:30
parent 53037c064f
commit ccface0748
2 changed files with 22 additions and 9 deletions

View File

@ -53,7 +53,7 @@ RUNTIMES = (
(20, 24) (20, 24)
) )
class TrigramSearchManager(models.Manager): class TrigramSearchManager(models.GeoManager):
def __init__(self, trigram_columns=[]): def __init__(self, trigram_columns=[]):
super(TrigramSearchManager, self).__init__() super(TrigramSearchManager, self).__init__()
self.trigram_columns = trigram_columns self.trigram_columns = trigram_columns
@ -229,6 +229,7 @@ class Route(models.Model):
distance = models.DecimalField(max_digits=3, decimal_places=1) distance = models.DecimalField(max_digits=3, decimal_places=1)
stages = models.IntegerField() stages = models.IntegerField()
class Meta: class Meta:
ordering = ['code'] ordering = ['code']

View File

@ -20,14 +20,26 @@ a:hover {
{% endblock %} {% endblock %}
{% block body %} {% block body %}
<ul id="stopList"> <div id="stopListWrapper" class="listColumn">
{% for s in stops %} <ul id="stopList">
<li> {% for stop in stops %}
<a href="{{ s.get_absolute_url }}" class="{% if s.point %} has_point {% else %} no_point {% endif %}">{{ s.name }}</a> <li>
</li> <a href="{{ stop.get_absolute_url }}">{{ s.name }}</a>
</li>
{% endfor %}
</ul>
</div>
<div id="routeListWrapper" class="listColumn">
<input class="listFilterInput" placeholder="Filter..." />
<ul id="routeList">
{% for route in routes %}
<li>
<a href="{{ route.get_absolute_url }}">{{ route.alias }}</a>
</li>
{% endfor %} {% endfor %}
</ul>
</ul> </div>
<div id="map"></div>
{% endblock %} {% endblock %}