Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve subtaxa aggregation view #559

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 29 additions & 23 deletions atlas/modeles/repositories/vmTaxrefRepository.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,34 @@ def searchEspece(connection, cd_ref):
"""
recherche l espece corespondant au cd_nom et tout ces fils
"""
sql = """
query = """
WITH limit_obs AS (
SELECT
:thiscdref AS cd_ref, min(yearmin) AS yearmin,
max(yearmax) AS yearmax, SUM(nb_obs) AS nb_obs
:cdRef AS cd_ref,
MIN(yearmin) AS yearmin,
MAX(yearmax) AS yearmax,
SUM(nb_obs) AS nb_obs
FROM atlas.vm_taxons
WHERE
cd_ref IN (SELECT * FROM atlas.find_all_taxons_childs(:thiscdref))
OR cd_ref = :thiscdref
WHERE cd_ref IN (SELECT * FROM atlas.find_all_taxons_childs(:cdRef))
OR cd_ref = :cdRef
)
SELECT taxref.*,
l.cd_ref, l.yearmin, l.yearmax, COALESCE(l.nb_obs, 0) AS nb_obs,
t2.patrimonial, t2.protection_stricte
FROM atlas.vm_taxref taxref
JOIN limit_obs l
ON l.cd_ref = taxref.cd_nom
LEFT JOIN atlas.vm_taxons t2
ON t2.cd_ref = taxref.cd_ref
WHERE taxref.cd_nom = :thiscdref
l.cd_ref,
l.yearmin,
l.yearmax,
COALESCE(l.nb_obs, 0) AS nb_obs,
t2.patrimonial,
t2.protection_stricte
FROM atlas.vm_taxref AS taxref
JOIN limit_obs AS l
ON l.cd_ref = taxref.cd_nom
LEFT JOIN atlas.vm_taxons AS t2
ON t2.cd_ref = taxref.cd_ref
WHERE taxref.cd_nom = :cdRef
"""
req = connection.execute(text(sql), thiscdref=cd_ref)
results = connection.execute(text(query), cdRef=cd_ref)
taxonSearch = dict()
for r in req:
for r in results:
nom_vern = None
if r.nom_vern:
nom_vern = (
Expand All @@ -54,7 +59,7 @@ def searchEspece(connection, cd_ref):
"protection": r.protection_stricte,
}

sql = """
query = """
SELECT
tax.lb_nom,
tax.nom_vern,
Expand All @@ -64,16 +69,17 @@ def searchEspece(connection, cd_ref):
tax.patrimonial,
tax.protection_stricte,
tax.nb_obs
FROM atlas.vm_taxons tax
JOIN atlas.bib_taxref_rangs br
ON br.id_rang = tax.id_rang
FROM atlas.vm_taxons AS tax
JOIN atlas.bib_taxref_rangs AS br
ON br.id_rang = tax.id_rang
WHERE tax.cd_ref IN (
SELECT * FROM atlas.find_all_taxons_childs(:thiscdref)
SELECT * FROM atlas.find_all_taxons_childs(:cdRef)
)
ORDER BY tax.lb_nom ASC, tax.nb_obs DESC
"""
req = connection.execute(text(sql), thiscdref=cd_ref)
results = connection.execute(text(query), cdRef=cd_ref)
listTaxonsChild = list()
for r in req:
for r in results:
temp = {
"lb_nom": r.lb_nom,
"nom_vern": r.nom_vern,
Expand Down
5 changes: 0 additions & 5 deletions atlas/static/mapAreas.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@ function displayObsTaxonMaille(areaCode, cd_ref) {
dataType: "json",
beforeSend: function () {
$("#loaderSpinner").show();
// $("#loadingGif").show();
// $("#loadingGif").attr(
// "src",
// configuration.URL_APPLICATION + "/static/images/loading.svg"
// );
}
}).done(function (observations) {
$("#loaderSpinner").hide();
Expand Down
4 changes: 3 additions & 1 deletion atlas/static/mapGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,9 @@ function displayGridLayerArea(observations) {
style: styleMaille,
});
currentLayer.addTo(map);
map.fitBounds(currentLayer.getBounds());
if (currentLayer.getBounds().isValid()) {
map.fitBounds(currentLayer.getBounds());
}

// ajout de la légende
generateLegendMaille();
Expand Down
72 changes: 37 additions & 35 deletions atlas/templates/speciesSheet/identityCard.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,19 @@ <h4 class="strong"><i>{{ taxon.taxonSearch.nom_complet_html|safe }} </i></h4>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="myModalLabel">
Taxon(s) agrégé(s) sur cette fiche
</h3>
<button type="button" class="close" data-dismiss="modal"
aria-label="Close"><span
aria-hidden="true">&times;</span></button>
<h3 class="modal-title" id="myModalLabel">Taxon(s) agrégé(s) sur cette
fiche</h3>
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<table class="table table-hover">
<table class="table table-hover table-responsive">
<thead>
<tr>
<th> {{ _('common.name') }}</th>
Expand All @@ -136,29 +138,31 @@ <h3 class="modal-title" id="myModalLabel">Taxon(s) agrégé(s) sur cette
</thead>
<tbody>
{% for child in taxon.listTaxonsChild %}
<a href="{{ url_for('main.ficheEspece', cd_nom=child.cd_ref) }}">
<tr>
<td>
{% if child.nom_vern != None %}
{{ child.nom_vern }}
{% else %}
-
</td>
{% endif %}
<td><i>{{ child.lb_nom }}</i></td>
<tr>
<td>
{% if child.nom_vern != None %}
{{ child.nom_vern }}
{% else %}
-
{% endif %}
</td>
<td> {{ child.lb_nom }} </td>
{% if configuration.PROTECTION %}
<td>
{% if child.protection != None %}
<a href="https://inpn.mnhn.fr/espece/cd_nom/{{ taxon.taxonSearch.cd_ref }}/tab/statut"
target="_blank">
target="_blank">
<img class="caractEspece" width="130px"
src="{{ url_for('static', filename='images/logo_protection.png') }}"
data-toggle="tooltip"
data-original-title="{{ _('this.taxon.has.a.protected.status') }}"
data-placement="right"></a>
src="{{ url_for('static', filename='images/logo_protection.png') }}"
data-toggle="tooltip"
data-original-title="{{ _('this.taxon.has.a.protected.status') }}"
data-placement="right"></a>
{% endif %}
</td>
{% endif %}
{% if config.DISPLAY_PATRIMONIALITE %}
<td>
{% if config.DISPLAY_PATRIMONIALITE and child.patrimonial in configuration.PATRIMONIALITE.config %}
{% if child.patrimonial in configuration.PATRIMONIALITE.config %}
<img
class="caractEspece" width="130px"
src="{{ url_for('static', filename=configuration.PATRIMONIALITE.config[child.patrimonial].icon) }}"
Expand All @@ -168,24 +172,22 @@ <h3 class="modal-title" id="myModalLabel">Taxon(s) agrégé(s) sur cette
>
{% endif %}
</td>
<td> {{ child.nb_obs | pretty }} </td>
<td>
<a href="{{ url_for('main.ficheEspece', cd_nom=child.cd_ref) }}">
<span id="ficheGlyficon" data-toggle="tooltip"
data-original-title="{{ _('check.species.sheet')}}"
data-placement="right"
class="fas fa-list"></span>
</a>
</td>

</tr>
</a>
{% endif %}
<td> {{ child.nb_obs | pretty }} </td>
<td>
<a href="{{ url_for('main.ficheEspece', cd_nom=child.cd_ref) }}">
<span id="ficheGlyficon" data-toggle="tooltip"
data-original-title="{{ _('check.species.sheet')}}"
data-placement="right"
class="fas fa-list"></span>
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>

</div>
</div>

Expand Down
8 changes: 8 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
CHANGELOG
=========

[Unreleased]
------------------

🐛 **Corrections**

- Correction et amélioration de l'affichage de la fenêtre listant les sous-taxons aggrégés (#558 par @jpm-cbna)


1.6.1 (2023-10-16)
------------------

Expand Down
Loading