X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=www%2Fmaps%2Fmaps%2Fcontrollers%2Flocation.py;fp=www%2Fmaps%2Fmaps%2Fcontrollers%2Flocation.py;h=dc38833e56032a9f80abeecaea2a2cde0596ba3f;hb=38f4b3b171a17f6f3e89be396c093355b12986c4;hp=c3e829858e5ea33699bd9c93b50d074c7a56a9f2;hpb=5485afbd4da2182072ef9756c65137729bf1eee5;p=dead%2Fcensus-tools.git 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') +