add page for areas listing

This commit is contained in:
Sanj 2012-02-16 19:10:12 +05:30
parent 5e775f097c
commit 53669913e9
3 changed files with 21 additions and 0 deletions

View File

@ -49,6 +49,8 @@ class Area(models.Model):
geometry = models.PolygonField(blank=True, null=True) geometry = models.PolygonField(blank=True, null=True)
alt_names = generic.GenericRelation("AlternativeName") alt_names = generic.GenericRelation("AlternativeName")
def get_absolute_url(self):
return "/area/%s/" % self.name
def __unicode__(self): def __unicode__(self):
return self.name return self.name

View File

@ -20,3 +20,19 @@ def route(request, alias):
'routeDetails': routeDetails 'routeDetails': routeDetails
}) })
return render_to_response("route.html", context) return render_to_response("route.html", context)
def areas(request):
context = RequestContext(request, {
'areas': Area.objects.all()
})
return render_to_response("areas.html", context)
def area(request, name):
area = get_object_or_404(Area, name=name)
stops = Stop.objects.filter(area=area)
context = RequestContext(request, {
'area': area,
'stops': stops
})
return render_to_response("area.html", context)

View File

@ -12,6 +12,9 @@ urlpatterns = patterns('',
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'^routes/$', 'mumbai.views.routes'),
(r'^route/(?P<alias>[a-zA-Z0-9\s\-]*?)/$', 'mumbai.views.route'), (r'^route/(?P<alias>[a-zA-Z0-9\s\-]*?)/$', 'mumbai.views.route'),
(r'^areas/$', 'mumbai.views.areas'),
(r'^area/(?P<name>.*?)/$', 'mumbai.views.area'),
# 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')),