diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-05-27 11:30:42 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-06-17 13:21:28 +0200 |
commit | 2f5706848f33f35863155f4f318352cec2be5994 (patch) | |
tree | 6707e69e607dc7b965a28a48519d6d70639cb145 | |
parent | 74155d628e2153eb90611027f2b4695619dd9bf5 (diff) | |
download | Ishtar-2f5706848f33f35863155f4f318352cec2be5994.tar.bz2 Ishtar-2f5706848f33f35863155f4f318352cec2be5994.zip |
Stats: better display of values in tables - operation type for default
-rw-r--r-- | archaeological_finds/models_finds.py | 2 | ||||
-rw-r--r-- | archaeological_operations/models.py | 2 | ||||
-rw-r--r-- | ishtar_common/static/js/ishtar.js | 11 | ||||
-rw-r--r-- | ishtar_common/views_item.py | 4 |
4 files changed, 12 insertions, 7 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index 7daf4cbec..ec8a5367e 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -815,9 +815,9 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem, # statistics STATISTIC_MODALITIES_OPTIONS = OrderedDict([ - ('base_finds__context_record__operation__year', _("Year")), ("base_finds__context_record__operation__operation_type__label", _("Operation type")), + ('base_finds__context_record__operation__year', _("Year")), ("base_finds__context_record__operation__towns__areas__label", _("Area")), ("base_finds__context_record__operation__towns__areas__parent__label", diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 5bc730018..b220ff1ec 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -574,8 +574,8 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem, NEW_QUERY_ENGINE = True # statistics STATISTIC_MODALITIES_OPTIONS = OrderedDict([ - ('year', _("Year")), ("operation_type__label", _("Operation type")), + ('year', _("Year")), ("towns__areas__label", _("Area")), ("towns__areas__parent__label", _("Extended area")), ("remains__label", _("Remains")), diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index 53223c477..66087b1ff 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -1507,9 +1507,12 @@ var _render_stats_table = function(stats_values, name){ if (inner_idx > 0) row_content += "<tr>"; row_content += "<td>" + stats_values[idx][1][inner_idx][0] + "</td>"; current_row.push(stats_values[idx][1][inner_idx][0]); - row_content += "<td>" + stats_values[idx][1][inner_idx][1] + "</td></tr>"; - current_row.push(stats_values[idx][1][inner_idx][1]); + var cvalue = stats_values[idx][1][inner_idx][1]; + current_row.push(cvalue); rows.push(current_row); + if (typeof cvalue.toLocaleString !== "undefined") + cvalue = cvalue.toLocaleString(); + row_content += "<td class='text-right'>" + cvalue + "</td></tr>"; } html += start_row + row_content; } @@ -1520,9 +1523,11 @@ var _render_stats_table = function(stats_values, name){ current_row.push(stats_values[idx][0]); var cvalue = stats_values[idx][1]; if (cvalue == null) cvalue = 0; - html += "<td>" + cvalue + "</td></tr>"; current_row.push(cvalue); rows.push(current_row); + if (typeof cvalue.toLocaleString !== "undefined") + cvalue = cvalue.toLocaleString(); + html += "<td class='text-right'>" + cvalue + "</td></tr>"; } } diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index 7b01f36b2..032d3e2c2 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -1233,14 +1233,14 @@ def _get_json_stats(items, stats_sum_variable, stats_modality_1, data.append([modality_1, []]) data[-1][1].append( (_format_modality(values[stats_modality_2]), - (values["sum"] or 0) * multiply) + int((values["sum"] or 0) * multiply)) ) else: q = q.order_by(stats_modality_1) for values in q.all(): modality_1 = values[stats_modality_1] data.append([_format_modality(modality_1), - (values["sum"] or 0) * multiply]) + int((values["sum"] or 0) * multiply)]) data = json.dumps({"data": data}) return HttpResponse(data, content_type='application/json') |