diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-01-22 16:44:40 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-04-24 19:38:56 +0200 |
commit | 2af3c31880b78d1b0110a168a9809c2c48111e40 (patch) | |
tree | 5b24e0c2251385e2237c5fed80d7354dceba2943 /ishtar_common | |
parent | 81a1008c26d0cc7cfdcbea14464746a7106d0e85 (diff) | |
download | Ishtar-2af3c31880b78d1b0110a168a9809c2c48111e40.tar.bz2 Ishtar-2af3c31880b78d1b0110a168a9809c2c48111e40.zip |
Manage X, Y, Z fields for context records, operations and sites
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/migrations/0084_ishtarsiteprofile_use_town_for_geo.py | 20 | ||||
-rw-r--r-- | ishtar_common/models.py | 2 | ||||
-rw-r--r-- | ishtar_common/utils.py | 9 |
3 files changed, 29 insertions, 2 deletions
diff --git a/ishtar_common/migrations/0084_ishtarsiteprofile_use_town_for_geo.py b/ishtar_common/migrations/0084_ishtarsiteprofile_use_town_for_geo.py new file mode 100644 index 000000000..182187e8b --- /dev/null +++ b/ishtar_common/migrations/0084_ishtarsiteprofile_use_town_for_geo.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2019-01-22 15:44 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ishtar_common', '0083_document_index_external_id'), + ] + + operations = [ + migrations.AddField( + model_name='ishtarsiteprofile', + name='use_town_for_geo', + field=models.BooleanField(default=True, verbose_name='Use town to locate when coordinates are missing'), + ), + ] diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 6a4a0930e..76e415368 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2151,6 +2151,8 @@ class IshtarSiteProfile(models.Model, Cached): preservation = models.BooleanField(_(u"Preservation module"), default=False) mapping = models.BooleanField(_(u"Mapping module"), default=False) + use_town_for_geo = models.BooleanField( + _(u"Use town to locate when coordinates are missing"), default=True) underwater = models.BooleanField(_(u"Underwater module"), default=False) parcel_mandatory = models.BooleanField( _(u"Parcel are mandatory for context records"), default=True) diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 55e3a3a75..20957c43e 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -476,8 +476,11 @@ def post_save_point(sender, **kwargs): if not kwargs.get('instance'): return instance = kwargs.get('instance') - point = None - point_2d = None + point = instance.point + point_2d = instance.point_2d + from ishtar_common.models import get_current_profile # not clean but utils + # must be loaded before models + profile = get_current_profile() if instance.x and instance.y and \ instance.spatial_reference_system and \ instance.spatial_reference_system.auth_name == 'EPSG' and \ @@ -488,6 +491,8 @@ def post_save_point(sender, **kwargs): point = convert_coordinates_to_point( instance.x, instance.y, instance.z, srid=instance.spatial_reference_system.srid) + elif profile.use_town_for_geo: + point_2d = instance.get_town_centroid() if point_2d != instance.point_2d or point != instance.point: instance.point = point instance.point_2d = point_2d |