merged with sanju's branch :)

This commit is contained in:
Johnson Chetty 2012-02-16 13:19:38 +01:00
commit f30b54218c
7 changed files with 112 additions and 2 deletions

View File

@ -107,6 +107,8 @@ class Stop(models.Model):
has_point.boolean = True
def get_absolute_url(self):
return "/admin/mumbai/stop/%d/" % self.id
class Route(models.Model):

View File

@ -1,6 +1,22 @@
# Create your views here.
from django.shortcuts import render_to_response
from models import *
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
def index(request):
return render_to_response("index.html", {})
def routes(request):
context = RequestContext(request, {
'routes': Route.objects.all()
})
return render_to_response("routes.html", context)
def route(request, alias):
route = get_object_or_404(Route, alias=alias)
routeDetails = RouteDetail.objects.filter(route=route).order_by('serial')
context = RequestContext(request, {
'route': route,
'routeDetails': routeDetails
})
return render_to_response("route.html", context)

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,18 @@
<!doctype html>
<html>
<head>
<script type="text/javascript" src="/static/js/jquery-1.7.1.min.js"></script>
<title>ChaloBEST: {% block title %} {% endblock %}</title>
{% block head %}
{% endblock %}
</head>
<body>
<div id="wrapper">
{% block body %}
{% endblock %}
</div>
</body>
</html>

View File

@ -0,0 +1,33 @@
{% extends 'base.html' %}
{% block title %} Route {{ route.alias }} {% endblock %}
{% block head %}
<style type="text/css">
.has_point {
color: #0f0;
}
.no_point {
color: #f00;
}
a:hover {
color: #00f;
}
</style>
{% endblock %}
{% block body %}
<ul id="stopList">
{% for r in routeDetails %}
<li>
<a href="{{ r.stop.get_absolute_url }}" class="{% if has_point %} has_point {% else %} no_point {% endif %}">{{ r.stop.name }}</a>
</li>
{% endfor %}
</ul>
{% endblock %}

View File

@ -0,0 +1,36 @@
{% extends 'base.html' %}
{% block title %}
Routes
{% endblock %}
{% block head %}
<script type="text/javascript">
$(function() {
$('#searchRoutes').change(function() {
var val = $(this).val().toLowerCase();
$('.route').each(function() {
var txt = $(this).text().toLowerCase();
if (txt.indexOf(val) != -1) {
$(this).show();
} else {
$(this).hide();
}
});
});
});
</script>
{% endblock %}
{% block body %}
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>
{% endfor %}
</ul>
{% endblock %}

View File

@ -10,7 +10,8 @@ urlpatterns = patterns('',
# (r'^chaloBEST/', include('chaloBEST.foo.urls')),
url(r'^$','chaloBEST.views.index', name='index'),
url(r'^static/(?P<path>.*)$','django.views.static.serve', {'document_root':'./static'}),
(r'^routes/$', 'mumbai.views.routes'),
(r'^route/(?P<alias>[a-zA-Z0-9]*?)/$', 'mumbai.views.route'),
# Uncomment the admin/doc line below to enable admin documentation:
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
#(r'^grappelli/', include('grappelli.urls')),