Commit ac935afa9c8c19e5735b940eb05773bf664bf958
1 parent
3d8865da
Exists in
master
Make warnings more salient.
Showing
3 changed files
with
40 additions
and
18 deletions
Show diff stats
flaskr/controllers/main_controller.py
@@ -254,7 +254,7 @@ def compute(): # process the queue of estimation requests | @@ -254,7 +254,7 @@ def compute(): # process the queue of estimation requests | ||
254 | if not _estimation.warnings: | 254 | if not _estimation.warnings: |
255 | _estimation.warnings = _warning_message | 255 | _estimation.warnings = _warning_message |
256 | else: | 256 | else: |
257 | - _estimation.warnings += u"\n" + _warning_message | 257 | + _estimation.warnings += _warning_message |
258 | # _estimation.warnings = u"%s\n%s" % \ | 258 | # _estimation.warnings = u"%s\n%s" % \ |
259 | # (_estimation.warnings, _warning_message) | 259 | # (_estimation.warnings, _warning_message) |
260 | db.session.commit() | 260 | db.session.commit() |
flaskr/models.py
@@ -12,7 +12,6 @@ from yaml import safe_load as yaml_load | @@ -12,7 +12,6 @@ from yaml import safe_load as yaml_load | ||
12 | from content import get_path | 12 | from content import get_path |
13 | 13 | ||
14 | 14 | ||
15 | - | ||
16 | # These are not the emission "models" in the scientific meaning of the word. | 15 | # These are not the emission "models" in the scientific meaning of the word. |
17 | # They are the SQL Database Models. | 16 | # They are the SQL Database Models. |
18 | # These are also named Entities, in other conventions (we're following flasks") | 17 | # These are also named Entities, in other conventions (we're following flasks") |
@@ -73,6 +72,22 @@ class Estimation(db.Model): | @@ -73,6 +72,22 @@ class Estimation(db.Model): | ||
73 | errors = db.Column(db.UnicodeText()) | 72 | errors = db.Column(db.UnicodeText()) |
74 | 73 | ||
75 | @property | 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 | def origins_count(self): | 91 | def origins_count(self): |
77 | return self.origin_addresses.strip().count("\n") + 1 | 92 | return self.origin_addresses.strip().count("\n") + 1 |
78 | 93 | ||
@@ -153,14 +168,16 @@ class Estimation(db.Model): | @@ -153,14 +168,16 @@ class Estimation(db.Model): | ||
153 | return self._models | 168 | return self._models |
154 | 169 | ||
155 | 170 | ||
171 | +# BACKOFFICE CONFIGURATION #################################################### | ||
172 | + | ||
156 | class EstimationView(ModelView): | 173 | class EstimationView(ModelView): |
157 | # Show only name and email columns in list view | 174 | # Show only name and email columns in list view |
158 | column_list = ( | 175 | column_list = ( |
159 | 'public_id', | 176 | 'public_id', |
177 | + 'link', | ||
160 | 'run_name', | 178 | 'run_name', |
161 | 'status', | 179 | 'status', |
162 | - 'first_name', | ||
163 | - 'last_name', | 180 | + 'author_name', |
164 | 'models_slugs', | 181 | 'models_slugs', |
165 | 'scenario', | 182 | 'scenario', |
166 | 'origins_count', | 183 | 'origins_count', |
@@ -173,7 +190,7 @@ class EstimationView(ModelView): | @@ -173,7 +190,7 @@ class EstimationView(ModelView): | ||
173 | # name and email fields | 190 | # name and email fields |
174 | # column_searchable_list = ('name', 'email') | 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 | # USERS ####################################################################### | 196 | # USERS ####################################################################### |
flaskr/templates/estimation.html
@@ -68,6 +68,23 @@ | @@ -68,6 +68,23 @@ | ||
68 | </div> | 68 | </div> |
69 | </div> | 69 | </div> |
70 | </div> | 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 | {% endif %} | 88 | {% endif %} |
72 | 89 | ||
73 | {% if not estimation.has_failed() %} | 90 | {% if not estimation.has_failed() %} |
@@ -171,18 +188,6 @@ | @@ -171,18 +188,6 @@ | ||
171 | 188 | ||
172 | <hr> | 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 | {#<div class="row">#} | 192 | {#<div class="row">#} |
188 | {# <div class="col-md-6">#} | 193 | {# <div class="col-md-6">#} |
@@ -334,7 +339,7 @@ jQuery(document).ready(function($){ | @@ -334,7 +339,7 @@ jQuery(document).ready(function($){ | ||
334 | var y_key = 'city'; | 339 | var y_key = 'city'; |
335 | var x_key = 'co2 (kg)'; | 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 | height = Math.max(300, 100+16*plots_config['cities_count']) - margin.top - margin.bottom; | 343 | height = Math.max(300, 100+16*plots_config['cities_count']) - margin.top - margin.bottom; |
339 | var width = Math.max(880, $(vizid).parent().width()); | 344 | var width = Math.max(880, $(vizid).parent().width()); |
340 | width = width - margin.left - margin.right; | 345 | width = width - margin.left - margin.right; |