diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-05-05 18:45:33 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-12 12:21:00 +0100 | 
| commit | 0f5d1297503a97e865ce211b2a0c801b21cfd613 (patch) | |
| tree | bc849de6718bea64126c2d25fc36973a0599fb1c | |
| parent | 810d6074789e3e6b11854f676314972a6952b486 (diff) | |
| download | Ishtar-0f5d1297503a97e865ce211b2a0c801b21cfd613.tar.bz2 Ishtar-0f5d1297503a97e865ce211b2a0c801b21cfd613.zip | |
Geodata: display geodata list on sheet
| -rw-r--r-- | archaeological_context_records/templates/ishtar/sheet_contextrecord.html | 20 | ||||
| -rw-r--r-- | archaeological_finds/models_finds.py | 7 | ||||
| -rw-r--r-- | archaeological_finds/templates/ishtar/sheet_find.html | 29 | ||||
| -rw-r--r-- | archaeological_operations/templates/ishtar/sheet_operation.html | 20 | ||||
| -rw-r--r-- | archaeological_operations/templates/ishtar/sheet_site.html | 9 | ||||
| -rw-r--r-- | fixtures/initial_data-auth-fr.json | 191 | ||||
| -rw-r--r-- | ishtar_common/models_common.py | 24 | ||||
| -rw-r--r-- | ishtar_common/templates/ishtar/blocks/sheet_geographic.html | 27 | 
8 files changed, 321 insertions, 6 deletions
| diff --git a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html index 1c3bb4b41..db952032c 100644 --- a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html +++ b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html @@ -14,6 +14,7 @@  {% with permission_view_own_document=permission_view_own_document %}  {% with permission_view_find=permission_view_find %}  {% with permission_view_own_find=permission_view_own_find %} +{% with permission_change_geo=permission_change_own_geovectordata|or_:permission_change_geovectordata %}  {% with can_view_documents=permission_view_own_document|or_:permission_view_document %}  {% with has_documents=item|safe_or:"documents.count" %} @@ -26,6 +27,7 @@  {% with has_finds=item|safe_or:"base_finds.count" %}  {% with display_finds=has_finds|and_:can_view_finds %}  {% with display_data=item.data %} +{% with display_geo=item.geodata.count %}  {% if output != "ODT" and output != "PDF"%}  <ul class="nav nav-tabs" id="{{window_id}}-tabs" role="tablist"> @@ -88,6 +90,15 @@          </a>      </li>      {% endif %} +    {% if not is_external and display_geo %} +    <li class="nav-item"> +        <a class="nav-link" id="{{window_id}}-geodata-tab" +           data-toggle="tab" href="#{{window_id}}-geodata" role="tab" +           aria-controls="{{window_id}}-geodata" aria-selected="false"> +            {% trans "Geographic data" %} +        </a> +    </li> +    {% endif %}      {% if display_data %}      <li class="nav-item">          <a class="nav-link" id="{{window_id}}-data-tab" @@ -320,6 +331,13 @@      </div>      {% endif %} +    {% if not is_external and display_geo %} +    <div class="tab-pane fade" id="{{window_id}}-geodata" +         role="tabpanel" aria-labelledby="{{window_id}}-geodata-tab"> +        {% with geo_item=item %}{% include "ishtar/blocks/sheet_geographic.html" %}{% endwith %} +    </div> +    {% endif %} +      {% if display_data %}      <div class="tab-pane fade" id="{{window_id}}-data"         role="tabpanel" aria-labelledby="{{window_id}}-data-tab"> @@ -328,6 +346,6 @@      {% endif %}  </div> -{% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} +{% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %}  {% endblock %} diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index ce9a5e4af..7d6d43d6c 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -66,7 +66,7 @@ from ishtar_common.models import (      SearchVectorConfig,      DocumentItem,  ) -from ishtar_common.models_common import HistoricalRecords, SerializeItem +from ishtar_common.models_common import HistoricalRecords, SerializeItem, GeoVectorData  from ishtar_common.utils import PRIVATE_FIELDS @@ -2052,6 +2052,11 @@ class Find(      def natural_key(self):          return (self.uuid,) +    def geoitem(self): +        return GeoVectorData.objects.filter( +            related_items_archaeological_finds_basefind__find__pk=self.pk +        ) +      @property      def short_class_name(self):          return _("FIND") diff --git a/archaeological_finds/templates/ishtar/sheet_find.html b/archaeological_finds/templates/ishtar/sheet_find.html index 5b6c38112..af10a8711 100644 --- a/archaeological_finds/templates/ishtar/sheet_find.html +++ b/archaeological_finds/templates/ishtar/sheet_find.html @@ -18,6 +18,7 @@  {# trick to set to null non existing variable #}  {% with permission_view_document=permission_view_document %}  {% with permission_view_own_document=permission_view_own_document %} +{% with permission_change_geo=permission_change_own_geovectordata|or_:permission_change_geovectordata %}  {% with non_modif_treatments_count=item.non_modif_treatments_count %}  {% with associated_treatment_files_count=item.associated_treatment_files_count %} @@ -26,6 +27,7 @@  {% with display_warehouse_treatments=item.container|or_:item.container_ref|or_:item.upstream_treatment|or_:item.downstream_treatment|or_:non_modif_treatments_count|or_:associated_treatment_files_count %}  {% with can_view_documents=permission_view_own_document|or_:permission_view_document %}  {% with display_documents=can_view_documents|and_:item.documents_count %} +{% with display_geo=item.geodata.count %}  {% if output != "ODT" and output != "PDF"%}  <ul class="nav nav-tabs" id="{{window_id}}-tabs" role="tablist"> @@ -70,6 +72,15 @@          </a>      </li>      {% endif %} +    {% if not is_external and display_geo %} +    <li class="nav-item"> +        <a class="nav-link" id="{{window_id}}-geodata-tab" +           data-toggle="tab" href="#{{window_id}}-geodata" role="tab" +           aria-controls="{{window_id}}-geodata" aria-selected="false"> +            {% trans "Geographic data" %} +        </a> +    </li> +    {% endif %}      {% if item.data %}      <li class="nav-item">          <a class="nav-link" id="{{window_id}}-json-tab" @@ -520,6 +531,22 @@        {% endif %}    </div>    {% endif %} + +  {% if not is_external and display_geo %} +  <div class="tab-pane fade" id="{{window_id}}-geodata" +       role="tabpanel" aria-labelledby="{{window_id}}-geodata-tab"> + +      {% for base_find in item.base_finds.all %} +      {% with geo_item=base_find %} +      <h3>{% if base_find.complete_identifier %}{{ base_find.complete_identifier }}{% else %}{{base_find.short_id}}{% endif %}</h3> +      {% with current_geolabel=base_find %} +      {% include "ishtar/blocks/sheet_geographic.html" %} +      {% endwith %} +      {% endfor %} + +  </div> +  {% endif %} +    {% if item.data and item.data|length > 0 %}    <div class="tab-pane fade" id="{{window_id}}-json"         role="tabpanel" aria-labelledby="{{window_id}}-json-tab"> @@ -528,7 +555,7 @@    {% endif %}  </div> -{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %} +{% endwith %} {% endwith %} {% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}  {% endblock %} diff --git a/archaeological_operations/templates/ishtar/sheet_operation.html b/archaeological_operations/templates/ishtar/sheet_operation.html index 76aadb444..e9568d5d7 100644 --- a/archaeological_operations/templates/ishtar/sheet_operation.html +++ b/archaeological_operations/templates/ishtar/sheet_operation.html @@ -18,6 +18,7 @@  {% with permission_view_own_contextrecord=permission_view_own_contextrecord %}  {% with permission_view_container=permission_view_container %}  {% with permission_view_own_container=permission_view_own_container %} +{% with permission_change_geo=permission_change_own_geovectordata|or_:permission_change_geovectordata %}  {% with display_data=item.data %}  {% with display_relations=item|safe_or:"right_relations.count|left_relations.count" %} @@ -31,6 +32,7 @@  {% with perm_find=permission_view_own_find|or_:permission_view_find %}  {% with has_finds=item|safe_or:"has_finds" %}  {% with display_finds=perm_find|and_:has_finds %} +{% with display_geo=item.geodata.count %}  {% if output != "ODT" and output != "PDF" %}  <ul class="nav nav-tabs" id="{{window_id}}-tabs" role="tablist"> @@ -86,6 +88,15 @@          </a>      </li>      {% endif %} +    {% if not is_external and display_geo %} +    <li class="nav-item"> +        <a class="nav-link" id="{{window_id}}-geodata-tab" +           data-toggle="tab" href="#{{window_id}}-geodata" role="tab" +           aria-controls="{{window_id}}-geodata" aria-selected="false"> +            {% trans "Geographic data" %} +        </a> +    </li> +    {% endif %}      {% if display_data %}      <li class="nav-item">          <a class="nav-link" id="{{window_id}}-data-tab" @@ -439,6 +450,13 @@      </div>      {% endif %} +    {% if not is_external and display_geo %} +    <div class="tab-pane fade" id="{{window_id}}-geodata" +         role="tabpanel" aria-labelledby="{{window_id}}-geodata-tab"> +        {% with geo_item=item %}{% include "ishtar/blocks/sheet_geographic.html" %}{% endwith %} +    </div> +    {% endif %} +      {% if display_data %}      <div class="tab-pane fade" id="{{window_id}}-data"         role="tabpanel" aria-labelledby="{{window_id}}-data-tab"> @@ -591,6 +609,6 @@ $(document).ready( function () {  } );  </script> -{% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} +{% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %}  {% endblock %}
\ No newline at end of file diff --git a/archaeological_operations/templates/ishtar/sheet_site.html b/archaeological_operations/templates/ishtar/sheet_site.html index a1125d202..e9004d875 100644 --- a/archaeological_operations/templates/ishtar/sheet_site.html +++ b/archaeological_operations/templates/ishtar/sheet_site.html @@ -1,5 +1,5 @@  {% extends "ishtar/sheet.html" %} -{% load i18n window_tables window_header window_ope_tables window_field from_dict %} +{% load i18n ishtar_helpers window_tables window_header window_ope_tables window_field from_dict %}  {% block head_title %}<strong>{{SITE_LABEL}}</strong> - {{item.cached_label}}{% endblock %} @@ -8,6 +8,8 @@  {% endblock %}  {% block content %} +{% with permission_change_geo=permission_change_own_geovectordata|or_:permission_change_geovectordata %} +{% with display_geo=item.geodata.count %}  <div class="row">      <div class="offset-lg-4 col-lg-4 offset-md-3 col-md-6 offset-sm-1 col-sm-10 col-12"> @@ -98,4 +100,9 @@  {% endif %}  {% endif %} +{% if not is_external and display_geo %} +{% with geo_item=item %}{% include "ishtar/blocks/sheet_geographic.html" %}{% endwith %} +{% endif %} + +{% endwith %} {% endwith %}  {% endblock %} diff --git a/fixtures/initial_data-auth-fr.json b/fixtures/initial_data-auth-fr.json index a74c70fa9..84d9b0792 100644 --- a/fixtures/initial_data-auth-fr.json +++ b/fixtures/initial_data-auth-fr.json @@ -4840,6 +4840,93 @@      }  },  { +    "model": "auth.permission", +    "fields": { +        "name": "Can add Geographic - Vector data", +        "content_type": [ +            "ishtar_common", +            "geovectordata" +        ], +        "codename": "add_geovectordata" +    } +}, +{ +    "model": "auth.permission", +    "fields": { +        "name": "Can change Geographic - Vector data", +        "content_type": [ +            "ishtar_common", +            "geovectordata" +        ], +        "codename": "change_geovectordata" +    } +}, +{ +    "model": "auth.permission", +    "fields": { +        "name": "Can delete Geographic - Vector data", +        "content_type": [ +            "ishtar_common", +            "geovectordata" +        ], +        "codename": "delete_geovectordata" +    } +}, +{ +    "model": "auth.permission", +    "fields": { +        "name": "Can view Geographic - Vector data", +        "content_type": [ +            "ishtar_common", +            "geovectordata" +        ], +        "codename": "view_geovectordata" +    } +},{ +    "model": "auth.permission", +    "fields": { +        "name": "Can view own Geographic - Vector data", +        "content_type": [ +            "ishtar_common", +            "geovectordata" +        ], +        "codename": "view_own_geovectordata" +    } +}, +{ +    "model": "auth.permission", +    "fields": { +        "name": "Can add own Geographic - Vector data", +        "content_type": [ +            "ishtar_common", +            "geovectordata" +        ], +        "codename": "add_own_geovectordata" +    } +}, +{ +    "model": "auth.permission", +    "fields": { +        "name": "Can change own Geographic - Vector data", +        "content_type": [ +            "ishtar_common", +            "geovectordata" +        ], +        "codename": "change_own_geovectordata" +    } +}, +{ +    "model": "auth.permission", +    "fields": { +        "name": "Can delete own Geographic - Vector data", +        "content_type": [ +            "ishtar_common", +            "geovectordata" +        ], +        "codename": "delete_own_geovectordata" +    } +}, +{      "model": "auth.group",      "fields": {          "name": "Op\u00e9rations : lecture", @@ -6116,5 +6203,109 @@              ]          ]      } +}, +{ +    "model": "auth.group", +    "fields": { +        "name": "Donn\u00e9es g\u00e9ographiques : ajout", +        "permissions": [ +            [ +                "add_geovectordata", +                "ishtar_common", +                "geovectordata" +            ] +        ] +    } +}, +{ +    "model": "auth.group", +    "fields": { +        "name": "Donn\u00e9es g\u00e9ographiques : lecture", +        "permissions": [ +            [ +                "view_geovectordata", +                "ishtar_common", +                "geovectordata" +            ] +        ] +    } +}, +{ +    "model": "auth.group", +    "fields": { +        "name": "Donn\u00e9es g\u00e9ographiques : modification", +        "permissions": [ +            [ +                "change_geovectordata", +                "ishtar_common", +                "geovectordata" +            ] +        ] +    } +}, +{ +    "model": "auth.group", +    "fields": { +        "name": "Donn\u00e9es g\u00e9ographiques : suppression", +        "permissions": [ +            [ +                "delete_geovectordata", +                "ishtar_common", +                "geovectordata" +            ] +        ] +    } +}, +{ +    "model": "auth.group", +    "fields": { +        "name": "Donn\u00e9es g\u00e9ographiques rattach\u00e9es : ajout", +        "permissions": [ +            [ +                "add_own_geovectordata", +                "ishtar_common", +                "geovectordata" +            ] +        ] +    } +}, +{ +    "model": "auth.group", +    "fields": { +        "name": "Donn\u00e9es g\u00e9ographiques rattach\u00e9es : lecture", +        "permissions": [ +            [ +                "view_own_geovectordata", +                "ishtar_common", +                "geovectordata" +            ] +        ] +    } +}, +{ +    "model": "auth.group", +    "fields": { +        "name": "Donn\u00e9es g\u00e9ographiques rattach\u00e9es : modification", +        "permissions": [ +            [ +                "change_own_geovectordata", +                "ishtar_common", +                "geovectordata" +            ] +        ] +    } +}, +{ +    "model": "auth.group", +    "fields": { +        "name": "Donn\u00e9es g\u00e9ographiques rattach\u00e9es : suppression", +        "permissions": [ +            [ +                "delete_own_geovectordata", +                "ishtar_common", +                "geovectordata" +            ] +        ] +    }  }  ] diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 12f8b0507..07aaa18ea 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -2079,8 +2079,16 @@ GEOJSON_POINT_TPL = {  } +GEOMETRY_TYPE_LBL = { +    "POINT": _("Point"), +    "MULTILINE": _("Line(s)"), +    "MULTIPOINTS": _("Points"), +    "MULTIPOLYGON": _("Polygon(s)"), +} + +  class GeoVectorData(Imported): -    name = models.TextField(_("Name"), default=_("Default")) +    name = models.TextField(_("Name"), default="-")      source_content_type = models.ForeignKey(          ContentType, related_name="content_type_geovectordata", on_delete=models.CASCADE      ) @@ -2145,6 +2153,12 @@ class GeoVectorData(Imported):          verbose_name = _("Geographic - Vector data")          verbose_name_plural = _("Geographic - Vector data")          unique_together = ("source_content_type", "source_id", "import_key") +        permissions = ( +            ("view_own_geovectordata", "Can view own Geographic - Vector data"), +            ("add_own_geovectordata", "Can add own Geographic - Vector data"), +            ("change_own_geovectordata", "Can change own Geographic - Vector data"), +            ("delete_own_geovectordata", "Can delete own Geographic - Vector data"), +        )      def __str__(self):          name = self.name @@ -2152,6 +2166,10 @@ class GeoVectorData(Imported):              name += f" ({str(self.data_type).lower()})"          return name +    @property +    def source_label(self): +        return str(self.source) +      def display_coordinates(self, rounded=5, dim=2, srid=4326, cache=True):          if not srid:              profile = get_current_profile() @@ -2356,6 +2374,10 @@ class GeoVectorData(Imported):          return ""      @property +    def geometry_type_label(self): +        return GEOMETRY_TYPE_LBL.get(self.geometry_type, "") + +    @property      def geojson(self):          if self.x or self.y or self.z:              geo = GEOJSON_POINT_TPL.copy() diff --git a/ishtar_common/templates/ishtar/blocks/sheet_geographic.html b/ishtar_common/templates/ishtar/blocks/sheet_geographic.html new file mode 100644 index 000000000..c5a413cc6 --- /dev/null +++ b/ishtar_common/templates/ishtar/blocks/sheet_geographic.html @@ -0,0 +1,27 @@ +{% load i18n window_field %} +<table id='{{window_id}}-geographic-data' class="table table-striped"> +    <tr> +        {% if permission_change_geo %}<th> </th>{% endif %} +        <th>{% trans "Main" %}</th> +        <th>{% trans "Data type" %}</th> +        <th>{% trans "Source" %}</th> +        <th>{% trans "Geometry" %}</th> +        <th>{% trans "Name" %}</th> +        <th>{% trans "Origin" %}</th> +        <th>{% trans "Provider" %}</th> +        <th>{% trans "Comment" %}</th> +    </tr> +{% for geo in geo_item.geodata.all %} +    <tr> +        {% if permission_change_geo %}<td><a href="#"><i class="fa fa-pencil"></i></a></td>{% endif %} +        <td>{% if geo.id == geo_item.main_geodata_id %}<i class="fa fa-check-circle text-success" aria-hidden="true"></i>{% else %}–{% endif %}</td> +        <td>{% if geo.data_type %}{{ geo.data_type }}{% else %}-{% endif %}</td> +        <td>{{ geo.source_label }}</td> +        <td>{{ geo.geometry_type_label }}</td> +        <td>{{ geo.name }}</td> +        <td>{% if geo.origin %}{{ geo.origin }}{% else %}-{% endif %}</td> +        <td>{% if geo.provider %}{{ geo.provider }}{% else %}-{% endif %}</td> +        <td>{% if geo.comment %}{{ geo.comment }}{% else %}-{% endif %}</td> +    </tr> +{% endfor %} +</table> | 
