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,7 +3,8 @@ import geopy
3 import sqlalchemy 3 import sqlalchemy
4 4
5 from flask import Blueprint, render_template, flash, request, redirect, \ 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 from flaskr.extensions import cache 9 from flaskr.extensions import cache
9 from flaskr.forms import LoginForm, EstimateForm 10 from flaskr.forms import LoginForm, EstimateForm
@@ -20,6 +21,14 @@ from yaml import safe_dump as yaml_dump @@ -20,6 +21,14 @@ from yaml import safe_dump as yaml_dump
20 main = Blueprint('main', __name__) 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 @main.route('/') 32 @main.route('/')
24 @cache.cached(timeout=1000) 33 @cache.cached(timeout=1000)
25 def home(): 34 def home():
@@ -115,7 +124,7 @@ def compute(): # process the queue of estimation requests @@ -115,7 +124,7 @@ def compute(): # process the queue of estimation requests
115 124
116 # GEOCODE ORIGINS ######################################################### 125 # GEOCODE ORIGINS #########################################################
117 126
118 - origins_addresses = estimation.origin_addresses.split("\n") 127 + origins_addresses = estimation.origin_addresses.strip().split("\n")
119 origins = [] 128 origins = []
120 129
121 for i in range(len(origins_addresses)): 130 for i in range(len(origins_addresses)):
@@ -147,7 +156,7 @@ def compute(): # process the queue of estimation requests @@ -147,7 +156,7 @@ def compute(): # process the queue of estimation requests
147 156
148 # GEOCODE DESTINATIONS #################################################### 157 # GEOCODE DESTINATIONS ####################################################
149 158
150 - destinations_addresses = estimation.destination_addresses.split("\n") 159 + destinations_addresses = estimation.destination_addresses.strip().split("\n")
151 destinations = [] 160 destinations = []
152 161
153 for i in range(len(destinations_addresses)): 162 for i in range(len(destinations_addresses)):
@@ -213,14 +222,17 @@ def compute(): # process the queue of estimation requests @@ -213,14 +222,17 @@ def compute(): # process the queue of estimation requests
213 # UTILITY PRIVATE FUNCTION(S) ############################################# 222 # UTILITY PRIVATE FUNCTION(S) #############################################
214 223
215 def get_city_key(_location): 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 def compute_one_to_many( 237 def compute_one_to_many(
226 _origin, 238 _origin,
flaskr/templates/estimate.html
@@ -55,7 +55,7 @@ @@ -55,7 +55,7 @@
55 <div class="form-group row"> 55 <div class="form-group row">
56 <div class="col-md-6"> 56 <div class="col-md-6">
57 {{ render_field(form.first_name) }} 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 </div> 59 </div>
60 <div class="col-md-6"> 60 <div class="col-md-6">
61 {{ render_field(form.last_name) }} 61 {{ render_field(form.last_name) }}
@@ -67,9 +67,11 @@ @@ -67,9 +67,11 @@
67 </div> 67 </div>
68 <div class="form-group"> 68 <div class="form-group">
69 {{ render_field(form.origin_addresses) }} 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 </div> 71 </div>
71 <div class="form-group"> 72 <div class="form-group">
72 {{ render_field(form.destination_addresses) }} 73 {{ render_field(form.destination_addresses) }}
  74 + <small class="form-text text-muted">Provide multiple destinations to compare them.</small>
73 </div> 75 </div>
74 <div class="form-check form-group"> 76 <div class="form-check form-group">
75 {{ render_checkbox(form.compute_optimal_destination) }} 77 {{ render_checkbox(form.compute_optimal_destination) }}