Skip to content

Commit

Permalink
feat(api): add admin interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Vergez committed Dec 6, 2022
1 parent 559a0ec commit 5cb5dfa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions backend/gn_module_monitoring/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"""

from flask import Blueprint, current_app
from geonature.core.admin.admin import admin as flask_admin
from geonature.utils.env import DB

from gn_module_monitoring.monitoring.admin import BibCategorieSiteView
from .command.cmd import commands

blueprint = Blueprint("monitorings", __name__)
Expand All @@ -12,3 +16,5 @@
blueprint.cli.short_help = "Commandes pour l" "administration du module MONITORINGS"
for cmd in commands:
blueprint.cli.add_command(cmd)

flask_admin.add_view(BibCategorieSiteView(DB.session, name="Catégories de sites", category="Monitorings"))
18 changes: 18 additions & 0 deletions backend/gn_module_monitoring/monitoring/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from flask_admin.contrib.sqla import ModelView
from geonature.core.admin.admin import CruvedProtectedMixin


from gn_module_monitoring.monitoring.models import BibCategorieSite


class BibCategorieSiteView(CruvedProtectedMixin, ModelView):
"""
Surcharge de l'administration des catégories de sites
"""

module_code = "MONITORINGS"
object_code = None

def __init__(self, session, **kwargs):
# Référence au model utilisé
super(BibCategorieSiteView, self).__init__(BibCategorieSite, session, **kwargs)

0 comments on commit 5cb5dfa

Please sign in to comment.