Commit ac935afa9c8c19e5735b940eb05773bf664bf958

Authored by Antoine Goutenoir
1 parent 3d8865da
Exists in master

Make warnings more salient.

flaskr/controllers/main_controller.py
... ... @@ -254,7 +254,7 @@ def compute(): # process the queue of estimation requests
254 254 if not _estimation.warnings:
255 255 _estimation.warnings = _warning_message
256 256 else:
257   - _estimation.warnings += u"\n" + _warning_message
  257 + _estimation.warnings += _warning_message
258 258 # _estimation.warnings = u"%s\n%s" % \
259 259 # (_estimation.warnings, _warning_message)
260 260 db.session.commit()
... ...
flaskr/models.py
... ... @@ -12,7 +12,6 @@ from yaml import safe_load as yaml_load
12 12 from content import get_path
13 13  
14 14  
15   -
16 15 # These are not the emission "models" in the scientific meaning of the word.
17 16 # They are the SQL Database Models.
18 17 # These are also named Entities, in other conventions (we're following flasks")
... ... @@ -73,6 +72,22 @@ class Estimation(db.Model):
73 72 errors = db.Column(db.UnicodeText())
74 73  
75 74 @property
  75 + def link(self):
  76 + return u"https://travel-footprint-calculator.irap.omp.eu/estimation/%s.html" \
  77 + % self.public_id
  78 +
  79 + @property
  80 + def author_name(self):
  81 + s = u""
  82 + if self.first_name:
  83 + s += self.first_name
  84 + if self.last_name:
  85 + s += (u" " if s else u"") + self.last_name
  86 + if self.institution:
  87 + s += (u" " if s else u"") + self.institution
  88 + return s
  89 +
  90 + @property
76 91 def origins_count(self):
77 92 return self.origin_addresses.strip().count("\n") + 1
78 93  
... ... @@ -153,14 +168,16 @@ class Estimation(db.Model):
153 168 return self._models
154 169  
155 170  
  171 +# BACKOFFICE CONFIGURATION ####################################################
  172 +
156 173 class EstimationView(ModelView):
157 174 # Show only name and email columns in list view
158 175 column_list = (
159 176 'public_id',
  177 + 'link',
160 178 'run_name',
161 179 'status',
162   - 'first_name',
163   - 'last_name',
  180 + 'author_name',
164 181 'models_slugs',
165 182 'scenario',
166 183 'origins_count',
... ... @@ -173,7 +190,7 @@ class EstimationView(ModelView):
173 190 # name and email fields
174 191 # column_searchable_list = ('name', 'email')
175 192  
176   - column_filters = ('first_name', 'last_name')
  193 + column_filters = ('first_name', 'last_name', 'status')
177 194  
178 195  
179 196 # USERS #######################################################################
... ...
flaskr/templates/estimation.html
... ... @@ -68,6 +68,23 @@
68 68 </div>
69 69 </div>
70 70 </div>
  71 +
  72 +<hr>
  73 +{% endif %}
  74 +
  75 +{% if estimation.warnings %}
  76 +<div class="row">
  77 + <div class="col-md-12 alert-warning card">
  78 + <div class="card-body">
  79 + <h3 class="card-title">Warnings</h3>
  80 + <pre>
  81 +{{ estimation.warnings }}
  82 + </pre>
  83 + </div>
  84 + </div>
  85 +</div>
  86 +
  87 +<hr>
71 88 {% endif %}
72 89  
73 90 {% if not estimation.has_failed() %}
... ... @@ -171,18 +188,6 @@
171 188  
172 189 <hr>
173 190  
174   -{% if estimation.warnings %}
175   -<div class="row">
176   - <div class="col-md-12 alert-warning card">
177   - <div class="card-body">
178   - <h3 class="card-title">Warnings</h3>
179   - <pre>
180   -{{ estimation.warnings }}
181   - </pre>
182   - </div>
183   - </div>
184   -</div>
185   -{% endif %}
186 191  
187 192 {#<div class="row">#}
188 193 {# <div class="col-md-6">#}
... ... @@ -334,7 +339,7 @@ jQuery(document).ready(function($){
334 339 var y_key = 'city';
335 340 var x_key = 'co2 (kg)';
336 341  
337   - var margin = {top: 40, right: 40, bottom: 150, left: 150},
  342 + var margin = {top: 40, right: 40, bottom: 150, left: 180},
338 343 height = Math.max(300, 100+16*plots_config['cities_count']) - margin.top - margin.bottom;
339 344 var width = Math.max(880, $(vizid).parent().width());
340 345 width = width - margin.left - margin.right;
... ...