diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-05-03 12:11:25 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-05-03 12:11:25 +0200 |
commit | 8fdea44cd91d3bdc1637d2595ffe5d94ce87ffae (patch) | |
tree | 0d10eb7f5150f733ac8eedd963adc1fa8752bef4 /archaeological_finds | |
parent | e60ba1a6a27e9ed4068d16743e8e80a6adec7f1e (diff) | |
download | Ishtar-8fdea44cd91d3bdc1637d2595ffe5d94ce87ffae.tar.bz2 Ishtar-8fdea44cd91d3bdc1637d2595ffe5d94ce87ffae.zip |
Fix material_type_label helper
Diffstat (limited to 'archaeological_finds')
-rw-r--r-- | archaeological_finds/models_finds.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index d825a8bb2..303d8e2b4 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -631,12 +631,18 @@ class BaseFind( return self._real_label() or self._temp_label() or "" def material_type_label(self): - find = self.get_last_find() - finds = [find and find.material_type.code or ""] - ope = self.context_record.operation - finds += [ope.code_patriarche or (str(ope.year) + "-" + ope.operation_code)] - finds += [self.context_record.label, str(self.material_index)] - return settings.JOINT.join(finds) + materials = set() + for f in self.find.all(): + for m in f.material_types.all(): + while m: + if m.code: + materials.add(m.code) + break + elif m.parent: + m = m.parent + else: + break + return "-".join(materials) def _real_label(self): if ( |