From 42787bd6f7c577ef3b2292ebf62f81ba3d42533f Mon Sep 17 00:00:00 2001 From: Sanj Date: Sun, 3 Jun 2012 18:35:28 +0530 Subject: [PATCH] put common js stuff into template, make map work across databrowse pages --- chaloBEST/imports/import_atlas.py | 2 +- chaloBEST/mumbai/admin.py | 5 +- chaloBEST/templates/area.html | 20 +--- chaloBEST/templates/databrowse_base.html | 114 +++++++++++++++++++++++ chaloBEST/templates/route.html | 105 +-------------------- chaloBEST/templates/stop.html | 15 ++- 6 files changed, 139 insertions(+), 122 deletions(-) create mode 100644 chaloBEST/templates/databrowse_base.html diff --git a/chaloBEST/imports/import_atlas.py b/chaloBEST/imports/import_atlas.py index 3590d23..f143f6b 100644 --- a/chaloBEST/imports/import_atlas.py +++ b/chaloBEST/imports/import_atlas.py @@ -20,7 +20,7 @@ def csvToJSON(): # print a if routeNo != '': if atlasDict.has_key(routeNo): - atlasDist[routeNo].append(a) + atlasDict[routeNo].append(a) else: atlasDict[routeNo] = [a] previousRoute = routeNo diff --git a/chaloBEST/mumbai/admin.py b/chaloBEST/mumbai/admin.py index ef39eac..af210c0 100644 --- a/chaloBEST/mumbai/admin.py +++ b/chaloBEST/mumbai/admin.py @@ -55,9 +55,8 @@ class UniqueRouteForm(forms.ModelForm): def __init__(self,*args, **kwargs): super(UniqueRouteForm,self).__init__(*args,**kwargs) - self.fields['from_stop'].queryset = Stop.objects.filter(pk__in=[rd.stop.id for rd in RouteDetail.objects.filter(route=self.instance.route).order_by('serial')]) - - self.fields['to_stop'].queryset = Stop.objects.filter(pk__in=[rd.stop.id for rd in RouteDetail.objects.filter(route=self.instance.route).order_by('serial')]) + self.fields['from_stop'].queryset = Stop.objects.filter(routedetail__route=self.instance.route).order_by('routedetail') + self.fields['to_stop'].queryset = Stop.objects.filter(routedetail__route=self.instance.route).order_by('routedetail') class UniqueRouteAdmin(admin.ModelAdmin): diff --git a/chaloBEST/templates/area.html b/chaloBEST/templates/area.html index d7266c8..7661142 100644 --- a/chaloBEST/templates/area.html +++ b/chaloBEST/templates/area.html @@ -1,22 +1,10 @@ -{% extends 'base.html' %} +{% extends 'databrowse_base.html' %} {% block title %} Area: {{ area.name }} {% endblock %} -{% block head %} - - +{% block api_url %} +var API_BASE = "/1.0/"; +var API_URL = API_BASE + 'area/' + "{{ area.slug }}"; {% endblock %} {% block body %} diff --git a/chaloBEST/templates/databrowse_base.html b/chaloBEST/templates/databrowse_base.html new file mode 100644 index 0000000..5d8fe61 --- /dev/null +++ b/chaloBEST/templates/databrowse_base.html @@ -0,0 +1,114 @@ +{% extends 'base.html' %} + +{% block title %} {% endblock %} + +{% block head %} + + + + +{% endblock %} + + +{% block body %} + +{% endblock %} diff --git a/chaloBEST/templates/route.html b/chaloBEST/templates/route.html index b3c70dd..e528587 100644 --- a/chaloBEST/templates/route.html +++ b/chaloBEST/templates/route.html @@ -1,107 +1,10 @@ -{% extends 'base.html' %} +{% extends 'databrowse_base.html' %} {% block title %} Route {{ route.alias }} {% endblock %} -{% block head %} - - - - +{% block api_url %} +var API_BASE = "/1.0/"; +var API_URL = API_BASE + 'route/' + "{{ route.alias }}"; {% endblock %} {% block body %} diff --git a/chaloBEST/templates/stop.html b/chaloBEST/templates/stop.html index e15ccdd..310bbc9 100644 --- a/chaloBEST/templates/stop.html +++ b/chaloBEST/templates/stop.html @@ -1,4 +1,17 @@ -{% extends 'base.html' %} +{% extends 'databrowse_base.html' %} + +{% block api_url %} +var API_BASE = "/1.0/"; +var API_URL = API_BASE + 'stop/' + "{{ stop.slug }}"; +{% endblock %} + +{% block geojson_callback %} + jsonLayer.addFeatures(geojson_format.read(obj)); + var maxExtent = jsonLayer.getDataExtent(); + map.zoomToExtent(maxExtent); + +{% endblock %} + {% block body %}