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 | 5b892b087eddf9f4132422259879584c82d1d678 (patch) | |
tree | 5b24e0c2251385e2237c5fed80d7354dceba2943 /ishtar_common/utils.py | |
parent | f985a5442260b8aadc78946c606538a55ff063da (diff) | |
download | Ishtar-5b892b087eddf9f4132422259879584c82d1d678.tar.bz2 Ishtar-5b892b087eddf9f4132422259879584c82d1d678.zip |
Manage X, Y, Z fields for context records, operations and sites
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r-- | ishtar_common/utils.py | 9 |
1 files changed, 7 insertions, 2 deletions
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 |