import logging
from flask import current_app, flash, request
from flask_admin.contrib.sqla import ModelView
from flask_admin.form import BaseForm
from wtforms import validators, Form
from sqlalchemy import select
from geonature.core.admin.utils import CruvedProtectedMixin
from geonature.core.gn_commons.models import TModules
from geonature.core.gn_permissions.models import PermObject
from geonature.core.gn_commons.schemas import TAdditionalFieldsSchema
from geonature.utils.env import DB
from marshmallow import ValidationError
[docs]
log = logging.getLogger()
[docs]
class BibFieldAdmin(CruvedProtectedMixin, ModelView):
[docs]
object_code = "ADDITIONAL_FIELDS"
[docs]
column_exclude_list = (
"field_values",
"additional_attributes",
"key_label",
"key_value",
"multiselect",
"api",
"id_list",
"unity",
)
[docs]
column_display_all_relations = True
[docs]
column_descriptions = {
"bib_nomenclature_type": "Si Type widget = Nomenclature",
"field_label": "Label du champ en interface",
"field_name": "Nom du champ en base de donnée",
"field_values": """Obligatoire si widget = select/multiselect/checkbox,radio (Format JSON : tableau de 'value/label'. Utilisez des doubles quotes pour les valeurs et les clés).
Exemple [{"label": "trois", "value": 3}, {"label": "quatre", "value": 4}]""",
"default_value": "La valeur par défaut doit être une des valeurs du champs 'Valeurs' ci-dessus. Pour les valeurs textuelles, il n'est pas nécessaire de remettre la valeur entre guillement",
"id_list": "Identifiant en BDD de la liste (pour Type widget = taxonomy/observers)",
"field_order": "Numéro d'ordonnancement du champs (si plusieurs champs pour le même module/objet/JDD)",
"modules": "Module(s) auquel le champs est rattaché. *Obligatoire",
"objects": "Objet(s) auquel le champs est rattaché. *Obligatoire",
"datasets": "Jeu(x) de donnés auquel le champs est rattaché",
}
[docs]
class TMobileAppsAdmin(CruvedProtectedMixin, ModelView):
[docs]
object_code = "MOBILE_APPS"
[docs]
column_list = (
"app_code",
"relative_path_apk",
"url_apk",
"package",
"version_code",
)
[docs]
column_labels = {
"app_code": "Code application",
"relative_path_apk": "Chemin relatif de l'APK",
"url_apk": "URL externe de l'APK",
"package": "Nom du paquet",
"version_code": "Code de version",
}
[docs]
column_exclude_list = "id_mobile_app"
[docs]
class TModulesAdmin(CruvedProtectedMixin, ModelView):
[docs]
object_code = "MODULES"
[docs]
can_view_details = True
[docs]
action_disallowed_list = ["delete"]
[docs]
column_searchable_list = (
"module_code",
"module_label",
)
[docs]
column_default_sort = [
("module_order", False),
("id_module", False),
]
[docs]
column_sortable_list = (
"module_order",
"module_code",
"module_label",
)
[docs]
column_list = (
"module_code",
"module_label",
"module_picto",
"module_order",
)
[docs]
column_details_list = (
"module_code",
"module_label",
"module_desc",
"module_comment",
"module_picto",
"module_doc_url",
"module_order",
)
[docs]
column_labels = {
"module_code": "Code",
"module_label": "Label",
"module_desc": "Description",
"module_comment": "Commentaire",
"module_picto": "Pictogramme",
"module_doc_url": "URL documentation",
"module_order": "Ordre",
}