Skip to content

Commit

Permalink
refactor(api): remove id_type in admin (#22)
Browse files Browse the repository at this point in the history
To replace it with a bib nomenclature type: TYPE_SITE
  • Loading branch information
mvergez authored and amandine-sahl committed Dec 8, 2023
1 parent 0ee1cee commit 6706af0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions backend/gn_module_monitoring/monitoring/admin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from flask_admin.contrib.sqla import ModelView
from geonature.core.admin.admin import CruvedProtectedMixin
from geonature.core.gn_commons.models import TNomenclatures
from geonature.utils.env import DB
from pypnnomenclature.models import TNomenclatures, BibNomenclaturesTypes

from gn_module_monitoring.monitoring.models import BibCategorieSite


SITE_TYPE = "TYPE_SITE"


class BibCategorieSiteView(CruvedProtectedMixin, ModelView):
"""
Surcharge de l'administration des catégories de sites
Expand All @@ -21,7 +24,8 @@ def __init__(self, session, **kwargs):
def get_only_type_site_asc():
return (
DB.session.query(TNomenclatures)
.filter(TNomenclatures.id_type == 116)
.join(TNomenclatures.nomenclature_type)
.filter(BibNomenclaturesTypes.mnemonique == SITE_TYPE)
.order_by(TNomenclatures.label_fr.asc())
)

Expand Down

0 comments on commit 6706af0

Please sign in to comment.