diff options
| -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 | ||||
| -rw-r--r-- | ishtar_common/migrations/0029_auto_20180218_1708.py | 20 | ||||
| -rw-r--r-- | ishtar_common/models.py | 2 | 
5 files changed, 62 insertions, 10 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 %} diff --git a/ishtar_common/migrations/0029_auto_20180218_1708.py b/ishtar_common/migrations/0029_auto_20180218_1708.py new file mode 100644 index 000000000..c1e10bfe5 --- /dev/null +++ b/ishtar_common/migrations/0029_auto_20180218_1708.py @@ -0,0 +1,20 @@ +# -*- 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', '0028_auto_20180214_1144'), +    ] + +    operations = [ +        migrations.AlterField( +            model_name='formatertype', +            name='formater_type', +            field=models.CharField(choices=[(b'IntegerFormater', 'Integer'), (b'FloatFormater', 'Float'), (b'UnicodeFormater', 'String'), (b'DateFormater', 'Date'), (b'TypeFormater', 'Type'), (b'YearFormater', 'Year'), (b'InseeFormater', 'INSEE code'), (b'StrToBoolean', 'String to boolean'), (b'FileFormater', 'File'), (b'UnknowType', 'Unknow type')], max_length=20, verbose_name='Formater type'), +        ), +    ] diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 74b2f4221..14b9849e1 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1464,7 +1464,7 @@ CURRENCY = ((u"€", _(u"Euro")),              (u"$", _(u"US dollar")))  FIND_INDEX_SOURCE = ((u"O", _(u"Operations")),                       (u"CR", _(u"Context records"))) -SITE_LABELS = [('site', _(u"Site")), ('entity', _(u"Archaeological entity"))] +SITE_LABELS = [('site', _(u"Site")), ('entity', _(u"Archaeological site"))]  class IshtarSiteProfile(models.Model, Cached): | 
