Skip to content

Commit

Permalink
Merge branch 'feat/monitoring_models' of github.com:PnX-SI/GeoNature …
Browse files Browse the repository at this point in the history
…into feat/monitoring_models
  • Loading branch information
amandine-sahl committed Oct 29, 2024
2 parents 87928dc + 7b32d02 commit fcff27e
Show file tree
Hide file tree
Showing 49 changed files with 1,354 additions and 856 deletions.
2 changes: 1 addition & 1 deletion backend/dependencies/TaxHub
Submodule TaxHub updated 40 files
+3 −2 .github/workflows/pytest.yml
+1 −1 VERSION
+1 −3 apptax/admin/admin_view.py
+31 −24 apptax/admin/static/js/taxref_autocomplete.js
+ apptax/admin/static/logo_inpn.png
+14 −16 apptax/admin/templates/admin/details_taxref.html
+4 −2 apptax/admin/templates/admin/edit_taxref.html
+5 −5 apptax/admin/templates/admin/list_taxref.html
+1 −1 apptax/migrations/versions/1cf2cdc94f9b_delete_attributesviews_per_kingdom.py
+29 −0 apptax/migrations/versions/6a20cd1055ec_drop_bib_themes_id_droit_column.py
+0 −139 apptax/taxonomie/commands/migrate_taxref/README.rst
+9 −6 apptax/taxonomie/commands/taxref.py
+17 −6 apptax/taxonomie/models.py
+43 −48 apptax/taxonomie/repositories.py
+56 −1 apptax/taxonomie/routesbdcstatuts.py
+7 −3 apptax/taxonomie/routesbibnoms.py
+82 −68 apptax/taxonomie/routestaxref.py
+26 −0 apptax/taxonomie/schemas.py
+33 −0 apptax/tests/test_bdcstatus.py
+117 −14 apptax/tests/test_taxref.py
+0 −1 apptax/utils/__init__.py
+2 −2 data/taxhubdata_atlas.sql
+14 −10 docs/changelog.md
+32 −4 docs/developpement.md
+ docs/images/MCD_taxonomie.png
+3 −0 docs/images/bdc_statut.png
+ docs/images/create_attribut.gif
+ docs/images/create_theme.gif
+ docs/images/create_use_lists.gif
+ docs/images/detail_taxon.gif
+3 −0 docs/images/update-taxref-cas-1.jpg
+3 −0 docs/images/update-taxref-cas-2.jpg
+3 −0 docs/images/update-taxref-cas-3.jpg
+3 −0 docs/images/update-taxref-cas-4.jpg
+1 −0 docs/index.rst
+202 −0 docs/update_taxref_version.md
+5 −2 install_app.sh
+1 −1 requirements-common.in
+1 −1 requirements-dev.txt
+1 −1 requirements.txt
21 changes: 14 additions & 7 deletions backend/geonature/core/gn_meta/models/aframework.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,21 @@ def user_actors(self):
def organism_actors(self):
return [actor.organism for actor in self.cor_af_actor if actor.organism]

def is_deletable(self):
return not (
db.session.scalar(
exists()
.select_from()
.where(TDatasets.id_acquisition_framework == self.id_acquisition_framework)
.select()
def has_datasets(self):
return db.session.scalar(
exists(TDatasets)
.where(TDatasets.id_acquisition_framework == self.id_acquisition_framework)
.select()
)

def has_child_acquisition_framework(self):
return db.session.scalar(
exists(TAcquisitionFramework)
.where(
TAcquisitionFramework.acquisition_framework_parent_id
== self.id_acquisition_framework
)
.select()
)

def has_instance_permission(self, scope, _through_ds=True):
Expand Down
12 changes: 9 additions & 3 deletions backend/geonature/core/gn_meta/routes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Routes for gn_meta
Routes for gn_meta
"""

import datetime as dt
Expand Down Expand Up @@ -772,11 +772,17 @@ def delete_acquisition_framework(scope, af_id):
raise Forbidden(
f"User {g.current_user} cannot delete acquisition framework {af.id_acquisition_framework}"
)
if not af.is_deletable():
if af.has_datasets():
raise Conflict(
"La suppression du cadre d’acquisition n'est pas possible "
"La suppression du cadre d’acquisition est impossible "
"car celui-ci contient des jeux de données."
)

if af.has_child_acquisition_framework():
raise Conflict(
"La suppression du cadre d’acquisition est impossible "
"car celui-ci est le parent d'autre(s) cadre(s) d'acquisition."
)
db.session.delete(af)
db.session.commit()

Expand Down
6 changes: 3 additions & 3 deletions backend/geonature/core/gn_synthese/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,11 +957,11 @@ def general_stats(permissions):
return data


@routes.route("/species_stats/<int:cd_ref>", methods=["GET"])
@routes.route("/taxon_stats/<int:cd_ref>", methods=["GET"])
@permissions.check_cruved_scope("R", get_scope=True, module_code="SYNTHESE")
@json_resp
def species_stats(scope, cd_ref):
"""Return stats about distinct species."""
def taxon_stats(scope, cd_ref):
"""Return stats for a specific taxon"""

area_type = request.args.get("area_type")

Expand Down
74 changes: 0 additions & 74 deletions backend/geonature/core/gn_synthese/synthese_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,77 +100,3 @@
{"prop": "dataset_name", "name": "JDD", "max_width": 200},
{"prop": "observers", "name": "observateur", "max_width": 200},
]


class DefaultProfile:
ENABLED = True
## DEFAULT PROFILE INDICATORS
LIST_INDICATORS = [
{
"name": "observation(s) valide(s)",
"matIcon": "search",
"field": "count_valid_data",
"type": "number",
},
{
"name": "Première observation",
"matIcon": "schedule",
"field": "first_valid_data",
"type": "date",
},
{
"name": "Dernière observation",
"matIcon": "search",
"field": "last_valid_data",
"type": "date",
},
{
"name": "Plage d'altitude(s)",
"matIcon": "terrain",
"field": ["altitude_min", "altitude_max"],
"unit": "m",
"type": "number",
},
]


class DefaultGeographicOverview:
pass


class DefaultSpeciesSheet:
## DEFAULT SPECIES SHEET INDICATORS
LIST_INDICATORS = [
{
"name": "observation(s)",
"matIcon": "search",
"field": "observation_count",
"type": "number",
},
{
"name": "observateur(s)",
"matIcon": "people",
"field": "observer_count",
"type": "number",
},
{
"name": "commune(s)",
"matIcon": "location_on",
"field": "area_count",
"type": "number",
},
{
"name": "Plage d'altitude(s)",
"matIcon": "terrain",
"unit": "m",
"type": "number",
"field": ["altitude_min", "altitude_max"],
},
{
"name": "Plage d'observation(s)",
"matIcon": "date_range",
"type": "date",
"field": ["date_min", "date_max"],
"separator": "-",
},
]
11 changes: 7 additions & 4 deletions backend/geonature/core/sensitivity/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@ def info():
q = (
select(
SensitivityRule.source,
func.count(SensitivityRule.id)
.where(SensitivityRule.active == True)
.label("active_count"),
func.count(SensitivityRule.id).label("active_count"),
func.count(SensitivityRule.id).label("total_count"),
)
.where(SensitivityRule.active == True)
.group_by(SensitivityRule.source)
.order_by(SensitivityRule.source)
)
Expand All @@ -70,6 +69,8 @@ def info():
select(func.count("*"))
.select_from(SensitivityRule)
.distinct(SensitivityRule.cd_nom)
.group_by(SensitivityRule.cd_nom)
.order_by(SensitivityRule.cd_nom)
)
)
)
Expand All @@ -80,13 +81,15 @@ def info():
.select_from(SensitivityRule)
.filter_by(active=True)
.distinct(SensitivityRule.cd_nom)
.group_by(SensitivityRule.cd_nom)
.order_by(SensitivityRule.cd_nom)
)
)
)
click.echo(
"\tRègles actives extrapolées aux taxons enfants : {}".format(
db.session.scalar(
func.count(func.distinct(SensitivityRuleCache.c.cd_nom)).label("count")
select(func.count(func.distinct(SensitivityRuleCache.c.cd_nom)).label("count"))
)
)
)
Expand Down
6 changes: 3 additions & 3 deletions backend/geonature/core/taxonomie/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class CruvedProtectedBibListesView(CruvedProtectedMixin, BibListesView):
module_code = "TAXHUB"
object_code = "LISTE"
object_code = "LISTES"
extra_actions_perm = {".import_cd_nom_view": "C"}


Expand All @@ -31,12 +31,12 @@ class CruvedProtectedTMediasView(CruvedProtectedMixin, TMediasView):

class CruvedProtectedBibAttributsView(CruvedProtectedMixin, BibAttributsView):
module_code = "TAXHUB"
object_code = "ATTRIBUT"
object_code = "ATTRIBUTS"


class CruvedProtectedBibThemes(CruvedProtectedMixin, BibThemesView):
module_code = "TAXHUB"
object_code = "THEME"
object_code = "THEMES"


def load_admin_views(app, admin):
Expand Down
Loading

0 comments on commit fcff27e

Please sign in to comment.