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')
+