Commit 461850db8fa1ed87f7d03cab05fcb1e74413a488

Authored by Antoine Goutenoir
1 parent 490282b4
Exists in master

Yet another joyful bundle of miscellaneous fixes.

- Favicon
- Fix three annoying bugs
- Réinforce one annoying bug
- UX
flaskr/controllers/main_controller.py
... ... @@ -3,7 +3,8 @@ import geopy
3 3 import sqlalchemy
4 4  
5 5 from flask import Blueprint, render_template, flash, request, redirect, \
6   - url_for, abort
  6 + url_for, abort, send_from_directory
  7 +from os.path import join
7 8  
8 9 from flaskr.extensions import cache
9 10 from flaskr.forms import LoginForm, EstimateForm
... ... @@ -20,6 +21,14 @@ from yaml import safe_dump as yaml_dump
20 21 main = Blueprint('main', __name__)
21 22  
22 23  
  24 +@main.route('/favicon.ico')
  25 +def favicon(): # we want it served from the root, not from static/
  26 + return send_from_directory(
  27 + join(main.root_path, '..', 'static', 'img'),
  28 + 'favicon.ico', mimetype='image/vnd.microsoft.icon'
  29 + )
  30 +
  31 +
23 32 @main.route('/')
24 33 @cache.cached(timeout=1000)
25 34 def home():
... ... @@ -115,7 +124,7 @@ def compute(): # process the queue of estimation requests
115 124  
116 125 # GEOCODE ORIGINS #########################################################
117 126  
118   - origins_addresses = estimation.origin_addresses.split("\n")
  127 + origins_addresses = estimation.origin_addresses.strip().split("\n")
119 128 origins = []
120 129  
121 130 for i in range(len(origins_addresses)):
... ... @@ -147,7 +156,7 @@ def compute(): # process the queue of estimation requests
147 156  
148 157 # GEOCODE DESTINATIONS ####################################################
149 158  
150   - destinations_addresses = estimation.destination_addresses.split("\n")
  159 + destinations_addresses = estimation.destination_addresses.strip().split("\n")
151 160 destinations = []
152 161  
153 162 for i in range(len(destinations_addresses)):
... ... @@ -213,14 +222,17 @@ def compute(): # process the queue of estimation requests
213 222 # UTILITY PRIVATE FUNCTION(S) #############################################
214 223  
215 224 def get_city_key(_location):
216   - _city_key = _location.address
217   - # if 'address100' in _location.raw['address']:
218   - # _city_key = _location.raw['address']['address100']
219   - if 'city' in _location.raw['address']:
220   - _city_key = _location.raw['address']['city']
221   - elif 'state' in _location.raw['address']:
222   - _city_key = _location.raw['address']['state']
223   - return _city_key
  225 +
  226 + return _location.address.split(',')[0]
  227 +
  228 + # _city_key = _location.address
  229 + # # if 'address100' in _location.raw['address']:
  230 + # # _city_key = _location.raw['address']['address100']
  231 + # if 'city' in _location.raw['address']:
  232 + # _city_key = _location.raw['address']['city']
  233 + # elif 'state' in _location.raw['address']:
  234 + # _city_key = _location.raw['address']['state']
  235 + # return _city_key
224 236  
225 237 def compute_one_to_many(
226 238 _origin,
... ...
flaskr/templates/estimate.html
... ... @@ -55,7 +55,7 @@
55 55 <div class="form-group row">
56 56 <div class="col-md-6">
57 57 {{ render_field(form.first_name) }}
58   - <small class="form-text text-muted">Please fill these as a courtesy to us.</small>
  58 + <small class="form-text text-muted">Fill these to say hello.</small>
59 59 </div>
60 60 <div class="col-md-6">
61 61 {{ render_field(form.last_name) }}
... ... @@ -67,9 +67,11 @@
67 67 </div>
68 68 <div class="form-group">
69 69 {{ render_field(form.origin_addresses) }}
  70 + <small class="form-text text-muted">Use <code>en_US</code> city and country names. No diacritics. The comma matters.</small>
70 71 </div>
71 72 <div class="form-group">
72 73 {{ render_field(form.destination_addresses) }}
  74 + <small class="form-text text-muted">Provide multiple destinations to compare them.</small>
73 75 </div>
74 76 <div class="form-check form-group">
75 77 {{ render_checkbox(form.compute_optimal_destination) }}
... ...