From 461850db8fa1ed87f7d03cab05fcb1e74413a488 Mon Sep 17 00:00:00 2001 From: Antoine Goutenoir Date: Fri, 25 Oct 2019 19:51:15 +0200 Subject: [PATCH] Yet another joyful bundle of miscellaneous fixes. --- flaskr/controllers/main_controller.py | 34 +++++++++++++++++++++++----------- flaskr/templates/estimate.html | 4 +++- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/flaskr/controllers/main_controller.py b/flaskr/controllers/main_controller.py index 6b06853..25156d4 100644 --- a/flaskr/controllers/main_controller.py +++ b/flaskr/controllers/main_controller.py @@ -3,7 +3,8 @@ import geopy import sqlalchemy from flask import Blueprint, render_template, flash, request, redirect, \ - url_for, abort + url_for, abort, send_from_directory +from os.path import join from flaskr.extensions import cache from flaskr.forms import LoginForm, EstimateForm @@ -20,6 +21,14 @@ from yaml import safe_dump as yaml_dump main = Blueprint('main', __name__) +@main.route('/favicon.ico') +def favicon(): # we want it served from the root, not from static/ + return send_from_directory( + join(main.root_path, '..', 'static', 'img'), + 'favicon.ico', mimetype='image/vnd.microsoft.icon' + ) + + @main.route('/') @cache.cached(timeout=1000) def home(): @@ -115,7 +124,7 @@ def compute(): # process the queue of estimation requests # GEOCODE ORIGINS ######################################################### - origins_addresses = estimation.origin_addresses.split("\n") + origins_addresses = estimation.origin_addresses.strip().split("\n") origins = [] for i in range(len(origins_addresses)): @@ -147,7 +156,7 @@ def compute(): # process the queue of estimation requests # GEOCODE DESTINATIONS #################################################### - destinations_addresses = estimation.destination_addresses.split("\n") + destinations_addresses = estimation.destination_addresses.strip().split("\n") destinations = [] for i in range(len(destinations_addresses)): @@ -213,14 +222,17 @@ def compute(): # process the queue of estimation requests # UTILITY PRIVATE FUNCTION(S) ############################################# def get_city_key(_location): - _city_key = _location.address - # if 'address100' in _location.raw['address']: - # _city_key = _location.raw['address']['address100'] - if 'city' in _location.raw['address']: - _city_key = _location.raw['address']['city'] - elif 'state' in _location.raw['address']: - _city_key = _location.raw['address']['state'] - return _city_key + + return _location.address.split(',')[0] + + # _city_key = _location.address + # # if 'address100' in _location.raw['address']: + # # _city_key = _location.raw['address']['address100'] + # if 'city' in _location.raw['address']: + # _city_key = _location.raw['address']['city'] + # elif 'state' in _location.raw['address']: + # _city_key = _location.raw['address']['state'] + # return _city_key def compute_one_to_many( _origin, diff --git a/flaskr/templates/estimate.html b/flaskr/templates/estimate.html index 0f4271b..e8d04c8 100644 --- a/flaskr/templates/estimate.html +++ b/flaskr/templates/estimate.html @@ -55,7 +55,7 @@
{{ render_field(form.first_name) }} - Please fill these as a courtesy to us. + Fill these to say hello.
{{ render_field(form.last_name) }} @@ -67,9 +67,11 @@
{{ render_field(form.origin_addresses) }} + Use en_US city and country names. No diacritics. The comma matters.
{{ render_field(form.destination_addresses) }} + Provide multiple destinations to compare them.
{{ render_checkbox(form.compute_optimal_destination) }} -- libgit2 0.21.2