summaryrefslogtreecommitdiff
path: root/archaeological_warehouse/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-08-22 14:34:52 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-08-22 14:34:52 +0200
commitee52553baad7d5b28a44e55a79104bbcf71e5ed1 (patch)
treef60b26ccf2c3156ec76cf6bbbf7f8fb291248fcf /archaeological_warehouse/models.py
parenta54bcab5291c57cb4e7e90b171ce98d3af5d45a2 (diff)
downloadIshtar-ee52553baad7d5b28a44e55a79104bbcf71e5ed1.tar.bz2
Ishtar-ee52553baad7d5b28a44e55a79104bbcf71e5ed1.zip
Warehouse sheet: better display of stats tables
Diffstat (limited to 'archaeological_warehouse/models.py')
-rw-r--r--archaeological_warehouse/models.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py
index 8bd6d2944..852b64706 100644
--- a/archaeological_warehouse/models.py
+++ b/archaeological_warehouse/models.py
@@ -181,8 +181,7 @@ class Warehouse(Address, DashboardFormItem, OwnPerms):
q = model.objects
cpath = []
for division, ref in path:
- lbl = u"{} {}".format(division.division, ref)
- cpath.append(lbl)
+ cpath.append(ref)
attrs = {
division_key + "__division": division,
division_key + "__reference": ref
@@ -192,12 +191,17 @@ class Warehouse(Address, DashboardFormItem, OwnPerms):
res[tuple(cpath)] = q.count()
res = [(k, res[k]) for k in res]
final_res, current_res, depth = [], [], 1
+ len_divisions = WarehouseDivisionLink.objects.filter(
+ warehouse=self).count()
for path, nb in sorted(res, key=lambda x: (len(x[0]), x[0])):
if depth != len(path):
final_res.append(current_res[:])
current_res = []
depth = len(path)
- current_res.append((u" | ".join(path), nb))
+ if path[-1] == '-':
+ continue
+ path = list(path) + ['' for idx in range(len_divisions - len(path))]
+ current_res.append((path, nb))
final_res.append(current_res[:])
return final_res