merged with sanju's branch :)
This commit is contained in:
commit
f30b54218c
|
@ -107,6 +107,8 @@ class Stop(models.Model):
|
||||||
|
|
||||||
has_point.boolean = True
|
has_point.boolean = True
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return "/admin/mumbai/stop/%d/" % self.id
|
||||||
|
|
||||||
|
|
||||||
class Route(models.Model):
|
class Route(models.Model):
|
||||||
|
|
|
@ -1,6 +1,22 @@
|
||||||
# Create your views here.
|
# 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):
|
def index(request):
|
||||||
return render_to_response("index.html", {})
|
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)
|
||||||
|
|
4
chaloBEST/static/js/jquery-1.7.1.min.js
vendored
Normal file
4
chaloBEST/static/js/jquery-1.7.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
18
chaloBEST/templates/base.html
Normal file
18
chaloBEST/templates/base.html
Normal 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>
|
33
chaloBEST/templates/route.html
Normal file
33
chaloBEST/templates/route.html
Normal 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 %}
|
36
chaloBEST/templates/routes.html
Normal file
36
chaloBEST/templates/routes.html
Normal 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 %}
|
|
@ -10,7 +10,8 @@ urlpatterns = patterns('',
|
||||||
# (r'^chaloBEST/', include('chaloBEST.foo.urls')),
|
# (r'^chaloBEST/', include('chaloBEST.foo.urls')),
|
||||||
url(r'^$','chaloBEST.views.index', name='index'),
|
url(r'^$','chaloBEST.views.index', name='index'),
|
||||||
url(r'^static/(?P<path>.*)$','django.views.static.serve', {'document_root':'./static'}),
|
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:
|
# Uncomment the admin/doc line below to enable admin documentation:
|
||||||
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||||
#(r'^grappelli/', include('grappelli.urls')),
|
#(r'^grappelli/', include('grappelli.urls')),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user