diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-04-08 11:22:33 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-04-24 19:42:35 +0200 |
commit | bc470e8759a77bb8ab150403232596598dcf3b4c (patch) | |
tree | 7a64c075b68d848cbae91b28e6089223247a3c45 | |
parent | dc5909e6545c9014c1b8676bed6a9c8927965cc7 (diff) | |
download | Ishtar-bc470e8759a77bb8ab150403232596598dcf3b4c.tar.bz2 Ishtar-bc470e8759a77bb8ab150403232596598dcf3b4c.zip |
Geo: warehouse and container localization are optionnal
-rw-r--r-- | archaeological_warehouse/templates/ishtar/sheet_container.html | 4 | ||||
-rw-r--r-- | archaeological_warehouse/templates/ishtar/sheet_warehouse.html | 4 | ||||
-rw-r--r-- | ishtar_common/migrations/0090_ishtarsiteprofile_locate_warehouses.py | 20 | ||||
-rw-r--r-- | ishtar_common/models.py | 7 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/blocks/sheet_coordinates.html | 4 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/blocks/sheet_simple_map.html | 2 | ||||
-rw-r--r-- | ishtar_common/utils.py | 11 | ||||
-rw-r--r-- | ishtar_common/views_item.py | 4 |
8 files changed, 48 insertions, 8 deletions
diff --git a/archaeological_warehouse/templates/ishtar/sheet_container.html b/archaeological_warehouse/templates/ishtar/sheet_container.html index f40020a92..ffc533513 100644 --- a/archaeological_warehouse/templates/ishtar/sheet_container.html +++ b/archaeological_warehouse/templates/ishtar/sheet_container.html @@ -43,9 +43,9 @@ <h3>{% trans "Localisation"%}</h3> <div class='row'> {% with geo_item=item %} - {% include "ishtar/blocks/sheet_simple_map.html"%} + {% if PROFILE.locate_warehouses %}{% include "ishtar/blocks/sheet_simple_map.html"%}{% endif %} <div class="col-12 col-lg-6 flex-wrap"> - {% include "ishtar/blocks/sheet_coordinates.html"%} + {% if PROFILE.locate_warehouses %}{% include "ishtar/blocks/sheet_coordinates.html"%}{% endif %} </div> {% endwith %} </div> diff --git a/archaeological_warehouse/templates/ishtar/sheet_warehouse.html b/archaeological_warehouse/templates/ishtar/sheet_warehouse.html index 6be884e8e..2d22df0fc 100644 --- a/archaeological_warehouse/templates/ishtar/sheet_warehouse.html +++ b/archaeological_warehouse/templates/ishtar/sheet_warehouse.html @@ -41,9 +41,9 @@ <h3>{% trans "Localisation"%}</h3> <div class='row'> {% with geo_item=item %} - {% include "ishtar/blocks/sheet_simple_map.html"%} + {% if PROFILE.locate_warehouses %}{% include "ishtar/blocks/sheet_simple_map.html"%}{% endif %} <div class="col-12 col-lg-6 flex-wrap"> - {% include "ishtar/blocks/sheet_coordinates.html"%} + {% if PROFILE.locate_warehouses %}{% include "ishtar/blocks/sheet_coordinates.html"%}{% endif %} {% with full=True %}{% include "ishtar/blocks/sheet_address_section.html" %}{% endwith %} </div> {% endwith %} diff --git a/ishtar_common/migrations/0090_ishtarsiteprofile_locate_warehouses.py b/ishtar_common/migrations/0090_ishtarsiteprofile_locate_warehouses.py new file mode 100644 index 000000000..817472b75 --- /dev/null +++ b/ishtar_common/migrations/0090_ishtarsiteprofile_locate_warehouses.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2019-04-05 16:51 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ishtar_common', '0089_import_csv_sep'), + ] + + operations = [ + migrations.AddField( + model_name='ishtarsiteprofile', + name='locate_warehouses', + field=models.BooleanField(default=False, help_text='Mapping module must be activated. With many containers and background task not activated, activating this option may consume many resources.', verbose_name='Locate warehouse and containers'), + ), + ] diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 959c31a1f..9bcfd4930 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2375,6 +2375,13 @@ class IshtarSiteProfile(models.Model, Cached): preservation = models.BooleanField(_(u"Preservation module"), default=False) mapping = models.BooleanField(_(u"Mapping module"), default=False) + locate_warehouses = models.BooleanField( + _(u"Locate warehouse and containers"), default=False, + help_text=_( + u"Mapping module must be activated. With many containers and " + u"background task not activated, activating this option may " + u"consume many resources.") + ) 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) diff --git a/ishtar_common/templates/ishtar/blocks/sheet_coordinates.html b/ishtar_common/templates/ishtar/blocks/sheet_coordinates.html index 1c5282c91..ff6218f1c 100644 --- a/ishtar_common/templates/ishtar/blocks/sheet_coordinates.html +++ b/ishtar_common/templates/ishtar/blocks/sheet_coordinates.html @@ -1,4 +1,5 @@ -{% load i18n window_field %}{% if geo_item.x or geo_item.y or geo_item.z %} +{% load i18n window_field %}{% if PROFILE.mapping %} +{% if geo_item.x or geo_item.y or geo_item.z %} <dl class="col-12"> <dt>{% trans "Coordinates" %}</dt> <dd> @@ -22,3 +23,4 @@ {% field_flex_full polygon_source geo_item.geo_polygon_source %} {% endif %} {% endif %} +{% endif %} diff --git a/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html b/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html index d94c6024c..ca93d7956 100644 --- a/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html +++ b/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html @@ -1,3 +1,4 @@ +{% if PROFILE.mapping %} {% if geo_item.point_2d or geo_item.multi_polygon %} <div class="col-12 col-lg-6 flex-wrap"> <div class="window-map" id="map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}"> @@ -16,3 +17,4 @@ display_map("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", null, {{geo_i {% endif %} </script> {% endif %} +{% endif %} diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 49730b496..3054d4a19 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -502,14 +502,21 @@ def post_save_geo(sender, **kwargs): from ishtar_common.models import get_current_profile # not clean but utils # is loaded before models + profile = get_current_profile() + if not profile.mapping: + return instance = kwargs.get('instance') + kls_name = instance.__class__.__name__ + + if not profile.locate_warehouses and ("Container" in kls_name + or "Warehouse" in kls_name): + return + current_source = "default" if hasattr(instance.__class__, "_meta"): current_source = unicode(instance.__class__._meta.verbose_name) - profile = get_current_profile() modified = False - if hasattr(instance, 'multi_polygon'): if instance.multi_polygon_source_item and \ instance.multi_polygon_source_item != current_source: # refetch diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index d53498fae..a2e0844ce 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -168,7 +168,9 @@ def show_item(model, name, extra_dct=None, model_for_perms=None): doc_type = 'type' in dct and dct.pop('type') url_name = u"/".join(reverse('show-' + name, args=['0', ''] ).split('/')[:-2]) + u"/" - dct['CURRENCY'] = get_current_profile().currency + profile = get_current_profile() + dct['PROFILE'] = profile + dct['CURRENCY'] = profile.currency dct['ENCODING'] = settings.ENCODING dct['DOT_GENERATION'] = settings.DOT_BINARY and True dct['current_window_url'] = url_name |