diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-09-28 16:39:06 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-09-28 16:39:06 +0200 |
commit | 778a7b6c0639f92f35dcdebaf62377e8e5828a67 (patch) | |
tree | cf9d518db7247270a7409f59003e0bc6e6c011e1 | |
parent | 41d8e7371da272c990710cf3c0bf0c3c23d93586 (diff) | |
download | Ishtar-778a7b6c0639f92f35dcdebaf62377e8e5828a67.tar.bz2 Ishtar-778a7b6c0639f92f35dcdebaf62377e8e5828a67.zip |
Sheet: add display of attached areas after towns (refs #4248)
-rw-r--r-- | archaeological_context_records/templates/ishtar/sheet_contextrecord.html | 2 | ||||
-rw-r--r-- | archaeological_finds/templates/ishtar/sheet_find.html | 2 | ||||
-rw-r--r-- | archaeological_operations/models.py | 6 | ||||
-rw-r--r-- | ishtar_common/models.py | 15 |
4 files changed, 19 insertions, 6 deletions
diff --git a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html index 2cb4c1dcb..c605addb9 100644 --- a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html +++ b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html @@ -30,7 +30,7 @@ {% field_flex "Type" item.unit %} {% field_flex "Excavation technic" item.excavation_technic %} {% field_flex_multiple "Chronology" item.datings %} - {% field_flex "Town" item.parcel.town %} + {% field_flex "Town" item.town.label_with_areas %} {% field_flex_multiple "Documentation" item.documentations %} {% field_flex "Opening date" item.opening_date %} {% field_flex "Closing date" item.closing_date %} diff --git a/archaeological_finds/templates/ishtar/sheet_find.html b/archaeological_finds/templates/ishtar/sheet_find.html index 6c14e5c53..a29ecc794 100644 --- a/archaeological_finds/templates/ishtar/sheet_find.html +++ b/archaeological_finds/templates/ishtar/sheet_find.html @@ -82,7 +82,7 @@ {% field_flex "Special interest" base_find.special_interest %} {% field_flex_detail "Context record" base_find.context_record %} - {% field_flex "Town" base_find.context_record.parcel.town %} + {% field_flex "Town" base_find.context_record.town.label_with_areas %} {% field_flex "Parcel" base_find.context_record.parcel %} {% field_flex_detail "Operation" base_find.context_record.operation %} {% field_flex_detail "Archaeological site" base_find.context_record.archaeological_site %} diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 42f1775df..2218c1b6f 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -270,8 +270,7 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter, return self.reference def towns_codes(self): - return [u"{} ({})".format(town.name, town.numero_insee) for town in - self.towns.all()] + return [town.label_with_areas for town in self.towns.all()] def towns_label(self): return u" - ".join(self.towns_codes()) @@ -840,8 +839,7 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter, return reverse('show-operation', args=[self.pk, '']) def towns_codes(self): - return [u"{} ({})".format(town.name, town.numero_insee) for town in - self.towns.all()] + return [town.label_with_areas for town in self.towns.all()] def towns_label(self): return u" - ".join(self.towns_codes()) diff --git a/ishtar_common/models.py b/ishtar_common/models.py index f6eeab72f..21216163a 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -3751,6 +3751,14 @@ class Town(Imported, models.Model): self.save() return self.cached_label + @property + def label_with_areas(self): + label = [self.name] + for area in self.areas.all(): + label.append(u" - ") + label.append(area.full_label) + return u" ".join(label) + def generate_geo(self, force=False): force = self.generate_limit(force=force) self.generate_center(force=force) @@ -3862,6 +3870,13 @@ class Area(HierarchicalType): return self.label return u"{} ({})".format(self.label, self.reference) + @property + def full_label(self): + label = [unicode(self)] + if self.parent: + label.append(self.parent.full_label) + return u" / ".join(label) + class OperationType(GeneralType): order = models.IntegerField(_(u"Order"), default=1) |