some fixes on search filter for areas and routes views

This commit is contained in:
Sanj 2012-02-16 19:29:33 +05:30
parent 7e4dd89b4a
commit cd295a2511
3 changed files with 11 additions and 8 deletions

View File

@ -124,6 +124,9 @@ class Route(models.Model):
distance = models.DecimalField(max_digits=3, decimal_places=1)
stages = models.IntegerField()
def get_absolute_url(self):
return "/route/%s/" % self.alias
def __unicode__(self):
return self.alias

View File

@ -7,9 +7,9 @@
{% block head %}
<script type="text/javascript">
$(function() {
$('#searchRoutes').change(function() {
$('#searchFilter').change(function() {
var val = $(this).val().toLowerCase();
$('.area').each(function() {
$('.listItem').each(function() {
var txt = $(this).text().toLowerCase();
if (txt.indexOf(val) != -1) {
$(this).show();
@ -24,10 +24,10 @@ $(function() {
{% endblock %}
{% block body %}
Filter: <input id="searchRoutes" />
Filter: <input id="searchFilter" />
<ul id="routesList">
{% for a in areas %}
<li class="route">
<li class="area listItem">
<a href="{{ a.get_absolute_url }}" title="view stops for route">{{ a.name }}</a>
</li>
{% endfor %}

View File

@ -7,9 +7,9 @@
{% block head %}
<script type="text/javascript">
$(function() {
$('#searchRoutes').change(function() {
$('#searchFilter').change(function() {
var val = $(this).val().toLowerCase();
$('.route').each(function() {
$('.listItem').each(function() {
var txt = $(this).text().toLowerCase();
if (txt.indexOf(val) != -1) {
$(this).show();
@ -27,8 +27,8 @@ $(function() {
Filter: <input id="searchRoutes" />
<ul id="routesList">
{% for r in routes %}
<li class="route">
<a href="/route/{{r.alias}}" title="view stops for route">{{ r.alias }}</a> - {{ r.from_stop.name }} to {{ r.to_stop.name }}
<li class="route listItem">
<a href="{{r.get_absolute_url}}" title="view stops for route">{{ r.alias }}</a> - {{ r.from_stop.name }} to {{ r.to_stop.name }}
</li>
{% endfor %}
</ul>