diff options
Diffstat (limited to 'archaeological_operations')
-rw-r--r-- | archaeological_operations/migrations/0017_archaeologicalsite_towns.py | 21 | ||||
-rw-r--r-- | archaeological_operations/models.py | 20 | ||||
-rw-r--r-- | archaeological_operations/templates/ishtar/sheet_site.html | 9 |
3 files changed, 41 insertions, 9 deletions
diff --git a/archaeological_operations/migrations/0017_archaeologicalsite_towns.py b/archaeological_operations/migrations/0017_archaeologicalsite_towns.py new file mode 100644 index 000000000..55696cc7a --- /dev/null +++ b/archaeological_operations/migrations/0017_archaeologicalsite_towns.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2018-02-18 17:08 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ishtar_common', '0029_auto_20180218_1708'), + ('archaeological_operations', '0016_auto_20180217_2257'), + ] + + operations = [ + migrations.AddField( + model_name='archaeologicalsite', + name='towns', + field=models.ManyToManyField(blank=True, related_name='sites', to='ishtar_common.Town', verbose_name='Towns'), + ), + ] diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index b9a2e0863..4be807478 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -90,10 +90,10 @@ post_delete.connect(post_save_cache, sender=ReportState) class ArchaeologicalSite(BaseHistorizedItem): SHOW_URL = 'show-site' - TABLE_COLS = ['reference', 'name', 'periods', 'remains'] + TABLE_COLS = ['reference', 'name', 'towns', 'periods', 'remains'] SLUG = 'site' BASE_SEARCH_VECTORS = ["reference", "name"] - M2M_SEARCH_VECTORS = ["periods__name", "remains__name"] + M2M_SEARCH_VECTORS = ["periods__name", "remains__name", "towns__name"] PARENT_SEARCH_VECTORS = ['operations'] reference = models.CharField(_(u"Reference"), max_length=200, unique=True) name = models.CharField(_(u"Name"), max_length=200, @@ -102,6 +102,8 @@ class ArchaeologicalSite(BaseHistorizedItem): blank=True) remains = models.ManyToManyField("RemainType", verbose_name=_(u'Remains'), blank=True) + towns = models.ManyToManyField(Town, verbose_name=_(u"Towns"), + related_name='sites', blank=True) class Meta: verbose_name = _(u"Archaeological site") @@ -123,13 +125,13 @@ class ArchaeologicalSite(BaseHistorizedItem): name = self.reference if self.name: name += u" %s %s" % (settings.JOINT, self.name) - if self.remains.count(): - name += u" {} {}".format( - settings.JOINT, - u", ".join([unicode(remain) for remain in self.remains.all()])) - if self.periods.count(): - name += u" [{}]".format( - u", ".join([unicode(period) for period in self.periods.all()])) + keys = [('towns', u" - {}"), ('remains', u" - {}"), + ('periods', u" [{}]")] + for k, lbl in keys: + if getattr(self, k).count(): + name += lbl.format(u", ".join([ + unicode(v) for v in getattr(self, k).all() + ])) return name @property diff --git a/archaeological_operations/templates/ishtar/sheet_site.html b/archaeological_operations/templates/ishtar/sheet_site.html index 211f4f003..87bec9bd7 100644 --- a/archaeological_operations/templates/ishtar/sheet_site.html +++ b/archaeological_operations/templates/ishtar/sheet_site.html @@ -42,6 +42,15 @@ {% field_flex_multiple "Remains" item.remains %} </div> +{% if not next %} +{% if item.towns.count %} +<h3>{% trans "Localisation"%}</h3> +<div class="row"> + {% field_flex_full "Towns" item.towns_codes|join:" ; " %} +</div> +{% endif %} +{% endif %} + {% trans "Operations" as operations %} {% if item.operations.count %} {% dynamic_table_document operations 'operations' 'archaeological_sites' item.pk '' output %} |