diff --git a/atlas/atlasRoutes.py b/atlas/atlasRoutes.py index cfb247321..752677ced 100644 --- a/atlas/atlasRoutes.py +++ b/atlas/atlasRoutes.py @@ -31,6 +31,7 @@ vmMedias, vmCorTaxonAttribut, vmTaxonsMostView, + vmStatsStatutTaxonCommRepository, ) @@ -292,6 +293,11 @@ def ficheZone(id_zone): connection = db.engine.connect() listTaxons = vmTaxonsRepository.getTaxonsZones(connection, id_zone) + taxon_pro_patri = vmStatsStatutTaxonCommRepository.get_nb_taxon_pro_pat_zone( + connection, id_zone + ) + nb_organism = vmOrganismsRepository.get_nb_organism_on_zone(connection, id_zone) + infosCommune = tZonesRepository.get_infos_zone(connection, id_zone) zone = tZonesRepository.getZoneFromIdZone(connection, id_zone) if current_app.config["AFFICHAGE_MAILLE"]: @@ -319,6 +325,9 @@ def ficheZone(id_zone): observers=observers, DISPLAY_EYE_ON_LIST=True, id_zone=id_zone, + taxonProPatri=taxon_pro_patri, + nb_organism=nb_organism, + infosCommune=infosCommune, ) diff --git a/atlas/messages.pot b/atlas/messages.pot index 9fdc21ee8..dac997b14 100644 --- a/atlas/messages.pot +++ b/atlas/messages.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2025-01-08 14:03+0100\n" +"POT-Creation-Date: 2025-01-09 21:50+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -127,7 +127,7 @@ msgstr "" msgid "atlas.presentation" msgstr "" -#: atlas/templates/areaSheet/_main.html:55 +#: atlas/templates/areaSheet/_main.html:63 msgid "last.obs.zone" msgstr "" @@ -274,6 +274,30 @@ msgstr "" msgid "observer" msgstr "" +#: atlas/templates/core/statHierarchy.html:23 +msgid "sources" +msgstr "" + +#: atlas/templates/core/statHierarchy.html:23 +msgid "source" +msgstr "" + +#: atlas/templates/core/statHierarchy.html:28 +msgid "first_observation" +msgstr "" + +#: atlas/templates/core/statHierarchy.html:33 +msgid "last_observation" +msgstr "" + +#: atlas/templates/core/statHierarchy.html:38 +msgid "protected_species" +msgstr "" + +#: atlas/templates/core/statHierarchy.html:44 +msgid "patrimonial_species" +msgstr "" + #: atlas/templates/core/tabTaxons.html:7 msgid "group" msgstr "" diff --git a/atlas/modeles/repositories/tZonesRepository.py b/atlas/modeles/repositories/tZonesRepository.py index a8f5de6c6..80b40c751 100644 --- a/atlas/modeles/repositories/tZonesRepository.py +++ b/atlas/modeles/repositories/tZonesRepository.py @@ -81,3 +81,43 @@ def getZonesObservationsChilds(connection, cd_ref): municipality = {"id_zone": r.id_zone, "area_name": r.area_name} municipalities.append(municipality) return municipalities + + +def get_infos_zone(connection, id_zone): + """ + Get zone info: + yearmin: fisrt observation year + yearmax: last observation year + id_parent: id parent zone + area_name: name parent zone + area_type_name: type parent zone + """ + sql = """ +SELECT + MIN(extract(YEAR FROM o.dateobs)) AS yearmin, + MAX(extract(YEAR FROM o.dateobs)) AS yearmax, + z.id_parent, + (SELECT area_name FROM atlas.zoning WHERE id_zone = z.id_parent) AS area_parent_name, + (SELECT type.type_name + FROM atlas.zoning AS zone + JOIN ref_geo.bib_areas_types type + ON type.id_type = zone.id_zoning_type + WHERE zone.id_zone = z.id_parent) AS area_parent_type_name +FROM atlas.vm_observations o + JOIN atlas.zoning z ON z.id_zone = o.id_zone +WHERE o.id_zone = :id_zone +GROUP BY z.id_parent + """ + + result = connection.execute(text(sql), id_zone=id_zone) + info_zone = dict() + for r in result: + info_zone = { + "yearmin": r.yearmin, + "yearmax": r.yearmax, + "id_parent": r.id_parent, + "parent_name": r.area_parent_name, + "parent_type_name": r.area_parent_type_name, + } + + return info_zone diff --git a/atlas/modeles/repositories/vmOrganismsRepository.py b/atlas/modeles/repositories/vmOrganismsRepository.py index e29abf5dc..2eacdc94f 100644 --- a/atlas/modeles/repositories/vmOrganismsRepository.py +++ b/atlas/modeles/repositories/vmOrganismsRepository.py @@ -88,3 +88,16 @@ def getTaxonRepartitionOrganism(connection, id_organism): temp = {"group2_inpn": r.group2_inpn, "nb_obs_group": int(r.nb_obs_group)} ListGroup.append(temp) return ListGroup + + +def get_nb_organism_on_zone(connection, id_zone): + sql = """SELECT DISTINCT COUNT(cto.nom_organism) AS nb_organism +FROM atlas.vm_observations o +JOIN atlas.vm_cor_taxon_organism cto ON cto.cd_ref = o.cd_ref +WHERE o.id_zone = :id_zone + """ + res = connection.execute(text(sql), id_zone=id_zone) + result = dict() + for r in res: + result = r.nb_organism + return result diff --git a/atlas/modeles/repositories/vmStatsStatutTaxonCommRepository.py b/atlas/modeles/repositories/vmStatsStatutTaxonCommRepository.py new file mode 100644 index 000000000..68fd10047 --- /dev/null +++ b/atlas/modeles/repositories/vmStatsStatutTaxonCommRepository.py @@ -0,0 +1,43 @@ +# -*- coding:utf-8 -*- + +from sqlalchemy.sql import text + + +# get nombre taxons protégés et nombre taxons patrimoniaux par communes +def get_nb_taxon_pro_pat_zone(connection, id_zone): + sql = """ +SELECT + COUNT(t.patrimonial) AS nb_taxon_patrimonial, COUNT(t.protection_stricte) AS nb_taxon_protege +FROM atlas.vm_observations o + JOIN atlas.vm_taxons t ON t.cd_ref=o.cd_ref + JOIN atlas.zoning zone ON st_intersects(o.the_geom_point, zone.the_geom_4326) +WHERE zone.id_zone = :thisIdZone + """ + req = connection.execute(text(sql), thisIdZone=id_zone) + taxonProPatri = dict() + for r in req: + taxonProPatri = {"nbTaxonPro": r.nb_taxon_protege, "nbTaxonPatri": r.nb_taxon_patrimonial} + return taxonProPatri + + +# # get stats sur les statuts des taxons par communes +# def getStatsStatutsTaxonsCommunes(connection, insee): +# sql = """ +# SELECT +# nb_taxon_que_pro, +# nb_taxon_que_patri, +# nb_taxon_pro_et_patri, +# nb_taxon_sans_statut +# FROM atlas.vm_stats_statut_taxon_comm a +# WHERE a.insee = :thisinsee +# """.encode('UTF-8') +# +# mesStatutsTaxons = connection.execute(text(sql), thisinsee=insee) +# for inter in mesStatutsTaxons: +# return [ +# {'label': "Taxons protégés", 'y': inter.nb_taxon_que_pro}, +# {'label': "Taxons patrimoniaux", 'y': inter.nb_taxon_que_patri}, +# {'label': "Taxons protégés et patrimoniaux", 'y': inter.nb_taxon_pro_et_patri}, +# {'label': "Autres taxons", 'y': inter.nb_taxon_sans_statut}, +# ] +# diff --git a/atlas/static/css/territorySheet.css b/atlas/static/css/territorySheet.css new file mode 100644 index 000000000..43b98fa03 --- /dev/null +++ b/atlas/static/css/territorySheet.css @@ -0,0 +1,20 @@ +img.patrimonial_img { + width: 1rem; +} + +.info_zone_card { + width: 100%; + justify-items: center; + padding: 1rem; +} + +.specie_list_map_block { + display: flex; + height: 100%; +} + +.stats_block { + display: flex; + flex-direction: column; + height: 100%; +} diff --git a/atlas/static/custom/images/logo_protection.png b/atlas/static/custom/images/logo_protection.png new file mode 100644 index 000000000..628610893 Binary files /dev/null and b/atlas/static/custom/images/logo_protection.png differ diff --git a/atlas/templates/areaSheet/_main.html b/atlas/templates/areaSheet/_main.html index 3106b4d8b..e225c4ac8 100644 --- a/atlas/templates/areaSheet/_main.html +++ b/atlas/templates/areaSheet/_main.html @@ -18,6 +18,7 @@ + {% endblock %} @@ -39,26 +40,34 @@ {% block content %} {# Ajoutez ici coeur de la page #} -
-
-
- {% if configuration.EXTENDED_AREAS %} - {% include 'templates/areaSheet/surrounding_areas.html' %} - {% endif %} +
+ +
+

{{ areaInfos.typeName }} - {{ areaInfos.areaName }}

{% include 'templates/core/statHierarchy.html' %}
- {% include 'templates/core/listTaxons.html' %}
-
-
-
{{ configuration.NB_LAST_OBS }} {{ _('last.obs.zone') }} - {{ areaInfos.areaName }}
+
+ +
+
+ {% if configuration.EXTENDED_AREAS %} + {% include 'templates/areaSheet/surrounding_areas.html' %} + {% endif %} +
+ {% include 'templates/core/listTaxons.html' %}
-
-
- {% include 'templates/core/loaderSpinner.html' %} -
+
+
+
{{ configuration.NB_LAST_OBS }} {{ _('last.obs.zone') }} + {{ areaInfos.areaName }}
+
+
+
+ {% include 'templates/core/loaderSpinner.html' %} +
+
diff --git a/atlas/templates/core/statHierarchy.html b/atlas/templates/core/statHierarchy.html index f65fd8216..837094d91 100644 --- a/atlas/templates/core/statHierarchy.html +++ b/atlas/templates/core/statHierarchy.html @@ -16,6 +16,42 @@
{{ observers | length | pretty }}
{{ _('observers')|lower if observers|length > 1 else _('observer')|lower }}
+ +
+ +
{{ nb_organism }} +
{{ _('sources')|lower if nb_organism > 1 else _('source')|lower }} +
+
+ +
{{ infosCommune.yearmin }} +
{{ _('first_observation')|lower }} +
+
+ +
{{ infosCommune.yearmax}} +
{{ _('last_observation')|lower }} +
+
+ +
{{ taxonProPatri.nbTaxonPatri }} +
{{ _('protected_species')|lower }} +
+ {% if configuration.DISPLAY_PATRIMONIALITE %} +
+ +
{{ taxonProPatri.nbTaxonPro }} +
{{ _('patrimonial_species')|lower }} +
+ {% endif %} + + {% if infosCommune.id_parent %} +
+ +
{{ infosCommune.parent_type_name }} +
{{ infosCommune.parent_name }} +
+ {% endif %}
{% endblock %} diff --git a/atlas/translations/en/LC_MESSAGES/messages.mo b/atlas/translations/en/LC_MESSAGES/messages.mo index 3ba22955b..ec0b45a13 100644 Binary files a/atlas/translations/en/LC_MESSAGES/messages.mo and b/atlas/translations/en/LC_MESSAGES/messages.mo differ diff --git a/atlas/translations/en/LC_MESSAGES/messages.po b/atlas/translations/en/LC_MESSAGES/messages.po index 684a367cd..b357d51f1 100644 --- a/atlas/translations/en/LC_MESSAGES/messages.po +++ b/atlas/translations/en/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2025-01-08 14:03+0100\n" +"POT-Creation-Date: 2025-01-09 21:50+0100\n" "PO-Revision-Date: 2021-07-12 12:12+0200\n" "Last-Translator: FULL NAME \n" "Language: en\n" @@ -134,7 +134,7 @@ msgstr "Search by area" msgid "atlas.presentation" msgstr "Atlas presentation" -#: atlas/templates/areaSheet/_main.html:55 +#: atlas/templates/areaSheet/_main.html:63 msgid "last.obs.zone" msgstr "Latest observations in the zone" @@ -284,6 +284,30 @@ msgstr "Observers" msgid "observer" msgstr "Observer" +#: atlas/templates/core/statHierarchy.html:23 +msgid "sources" +msgstr "sources" + +#: atlas/templates/core/statHierarchy.html:23 +msgid "source" +msgstr "source" + +#: atlas/templates/core/statHierarchy.html:28 +msgid "first_observation" +msgstr "first observation" + +#: atlas/templates/core/statHierarchy.html:33 +msgid "last_observation" +msgstr "last observation" + +#: atlas/templates/core/statHierarchy.html:38 +msgid "protected_species" +msgstr "protected species" + +#: atlas/templates/core/statHierarchy.html:44 +msgid "patrimonial_species" +msgstr "patrimonial species" + #: atlas/templates/core/tabTaxons.html:7 msgid "group" msgstr "Group" diff --git a/atlas/translations/fr/LC_MESSAGES/messages.mo b/atlas/translations/fr/LC_MESSAGES/messages.mo index a37cb59bd..4ce17fdfb 100644 Binary files a/atlas/translations/fr/LC_MESSAGES/messages.mo and b/atlas/translations/fr/LC_MESSAGES/messages.mo differ diff --git a/atlas/translations/fr/LC_MESSAGES/messages.po b/atlas/translations/fr/LC_MESSAGES/messages.po index 120c51fc7..d269e10ac 100644 --- a/atlas/translations/fr/LC_MESSAGES/messages.po +++ b/atlas/translations/fr/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2025-01-08 14:03+0100\n" +"POT-Creation-Date: 2025-01-09 21:50+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language: fr\n" @@ -136,7 +136,7 @@ msgstr "Recherche par zone" msgid "atlas.presentation" msgstr "Présentation de l'atlas" -#: atlas/templates/areaSheet/_main.html:55 +#: atlas/templates/areaSheet/_main.html:63 msgid "last.obs.zone" msgstr "Dernière observations : " @@ -286,6 +286,30 @@ msgstr "Observateurs" msgid "observer" msgstr "Observateur" +#: atlas/templates/core/statHierarchy.html:23 +msgid "sources" +msgstr "sources" + +#: atlas/templates/core/statHierarchy.html:23 +msgid "source" +msgstr "source" + +#: atlas/templates/core/statHierarchy.html:28 +msgid "first_observation" +msgstr "première observation" + +#: atlas/templates/core/statHierarchy.html:33 +msgid "last_observation" +msgstr "dernière observation" + +#: atlas/templates/core/statHierarchy.html:38 +msgid "protected_species" +msgstr "espèces protectégés" + +#: atlas/templates/core/statHierarchy.html:44 +msgid "patrimonial_species" +msgstr "espèces patrimoniales" + #: atlas/templates/core/tabTaxons.html:7 msgid "group" msgstr "Groupe" diff --git a/atlas/translations/it/LC_MESSAGES/messages.mo b/atlas/translations/it/LC_MESSAGES/messages.mo index 8fbc49b84..78434f80d 100644 Binary files a/atlas/translations/it/LC_MESSAGES/messages.mo and b/atlas/translations/it/LC_MESSAGES/messages.mo differ diff --git a/atlas/translations/it/LC_MESSAGES/messages.po b/atlas/translations/it/LC_MESSAGES/messages.po index 4da1e6cce..09803c0a6 100644 --- a/atlas/translations/it/LC_MESSAGES/messages.po +++ b/atlas/translations/it/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2025-01-08 14:03+0100\n" +"POT-Creation-Date: 2025-01-09 21:50+0100\n" "PO-Revision-Date: 2021-07-19 09:53+0200\n" "Last-Translator: FULL NAME \n" "Language: it\n" @@ -135,7 +135,7 @@ msgstr "Ricerca per zona" msgid "atlas.presentation" msgstr "Presentazione dell'atlante" -#: atlas/templates/areaSheet/_main.html:55 +#: atlas/templates/areaSheet/_main.html:63 msgid "last.obs.zone" msgstr "Ultime osservazioni: " @@ -285,6 +285,30 @@ msgstr "Osservatori" msgid "observer" msgstr "Osservatori" +#: atlas/templates/core/statHierarchy.html:23 +msgid "sources" +msgstr "fonti" + +#: atlas/templates/core/statHierarchy.html:23 +msgid "source" +msgstr "Origine" + +#: atlas/templates/core/statHierarchy.html:28 +msgid "first_observation" +msgstr "prima osservazione" + +#: atlas/templates/core/statHierarchy.html:33 +msgid "last_observation" +msgstr "ultima osservazione" + +#: atlas/templates/core/statHierarchy.html:38 +msgid "protected_species" +msgstr "specie protette" + +#: atlas/templates/core/statHierarchy.html:44 +msgid "patrimonial_species" +msgstr "specie del patrimonio" + #: atlas/templates/core/tabTaxons.html:7 msgid "group" msgstr "Gruppo" diff --git a/docs/changelog.rst b/docs/changelog.rst index 49c168165..1e937784a 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -10,6 +10,7 @@ CHANGELOG - Ajout du lien "Données personelles" dans le pied de page (#527 @juggler31) - Suppression du support des installations sans TaxHub - Changement de la notion de "commune" en notion de "zoning" (#545 @juggler31) +- Ajout de statistique sur la fiche de "zoning" (#540 @juggler31) 🐛 **Corrections**