Skip to content

Commit

Permalink
Merge issue #558
Browse files Browse the repository at this point in the history
Merge branch 'feat/sinp' into feat/sinp-paca
  • Loading branch information
jpm-cbna committed May 7, 2024
2 parents 876c16f + 81b4705 commit 651abf0
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 63 deletions.
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 @@ -56,7 +61,7 @@ def searchEspece(connection, cd_ref):
"protection": r.protection_stricte,
}

sql = """
query = """
SELECT
tax.lb_nom,
tax.nom_vern,
Expand All @@ -66,16 +71,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 @@ -330,7 +330,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
70 changes: 36 additions & 34 deletions atlas/templates/speciesSheet/identityCard.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,16 @@ <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">
Expand All @@ -134,29 +136,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> {{ child.lb_nom }} </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 @@ -166,24 +170,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

0 comments on commit 651abf0

Please sign in to comment.