summaryrefslogtreecommitdiff
path: root/archaeological_warehouse/models.py
diff options
context:
space:
mode:
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