diff options
Diffstat (limited to 'ishtar_common')
| -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 | 
6 files changed, 44 insertions, 4 deletions
| 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 | 
