From 38f4b3b171a17f6f3e89be396c093355b12986c4 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 19 Feb 2010 08:56:05 -0500 Subject: [PATCH] Made the routing Javascript render inline on a new view, location/route. --- www/maps/maps/controllers/location.py | 53 +++++++++++---------- www/maps/maps/templates/base.mako | 10 +--- www/maps/maps/templates/location/index.mako | 5 +- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/www/maps/maps/controllers/location.py b/www/maps/maps/controllers/location.py index c3e8298..dc38833 100644 --- a/www/maps/maps/controllers/location.py +++ b/www/maps/maps/controllers/location.py @@ -11,35 +11,38 @@ log = logging.getLogger(__name__) class LocationController(BaseController): - def index(self): - c.load_maps = False + def index(self): + return render('/location/index.mako') - if request.method == 'POST': - c.load_maps = True - # Get the contents of the uploaded files. - producers_data = request.POST['producers'].value.splitlines() - consumers_data = request.POST['consumers'].value.splitlines() - - producers_csv = csv.DictReader(producers_data) - consumers_csv = csv.DictReader(consumers_data) + def route(self): + if request.method != 'POST': + return 'You should have posted some data.' + + # Get the contents of the uploaded files. + producers_data = request.POST['producers'].value.splitlines() + consumers_data = request.POST['consumers'].value.splitlines() - # Create a big json string to pass as a parameter to our - # javascript page. - json_objects = [] + producers_csv = csv.DictReader(producers_data) + consumers_csv = csv.DictReader(consumers_data) - for row in producers_csv: - # Add the producers to the output, one at a time. - # But first, insert a 'type' field. - row['type'] = 'producer' - json_objects.append(row) + # Create a big json string to pass as a parameter to our + # javascript page. + json_objects = [] - for row in consumers_csv: - # Do the same thing for the consumers. - row['type'] = 'consumer' - json_objects.append(row) + for row in producers_csv: + # Add the producers to the output, one at a time. + # But first, insert a 'type' field. + row['type'] = 'producer' + json_objects.append(row) - c.json = json.dumps(json_objects) - - return render('/location/index.mako') + for row in consumers_csv: + # Do the same thing for the consumers. + row['type'] = 'consumer' + json_objects.append(row) + c.json = json.dumps(json_objects) + c.js = render('javascript/routing.mako') + + return render('location/route.mako') + diff --git a/www/maps/maps/templates/base.mako b/www/maps/maps/templates/base.mako index 0b14045..6b0c649 100644 --- a/www/maps/maps/templates/base.mako +++ b/www/maps/maps/templates/base.mako @@ -10,14 +10,8 @@ ${h.stylesheet_link('/stylesheets/reset.css')} ${h.stylesheet_link('/stylesheets/common.css')} - - % if c.load_maps: - - - - % endif + + ${next.scripts()} diff --git a/www/maps/maps/templates/location/index.mako b/www/maps/maps/templates/location/index.mako index 4f80d54..c65e7e5 100644 --- a/www/maps/maps/templates/location/index.mako +++ b/www/maps/maps/templates/location/index.mako @@ -1,8 +1,11 @@ <%inherit file="/base.mako"/>\ +<%def name="scripts()"> + +

Generate KML Routes

-
+
Producer/Consumer Upload -- 2.44.2