Code source de geonature.core.gn_commons.models.additional_fields

"""
    Modèles du schéma gn_commons
"""

from sqlalchemy.dialects.postgresql import JSONB

from utils_flask_sqla.serializers import serializable


from geonature.utils.env import DB

from .base import cor_field_module, cor_field_object, cor_field_dataset
from geonature.core.gn_meta.models import TDatasets
from geonature.core.gn_permissions.models import PermObject


@serializable
[docs] class TAdditionalFields(DB.Model):
[docs] __tablename__ = "t_additional_fields"
[docs] __table_args__ = {"schema": "gn_commons"}
[docs] id_field = DB.Column(DB.Integer, primary_key=True)
[docs] field_name = DB.Column(DB.String, nullable=False)
[docs] field_label = DB.Column(DB.String, nullable=False)
[docs] required = DB.Column(DB.Boolean)
[docs] description = DB.Column(DB.String)
[docs] quantitative = DB.Column(DB.Boolean, default=False)
[docs] unity = DB.Column(DB.String(50))
[docs] field_values = DB.Column(JSONB)
[docs] code_nomenclature_type = DB.Column( DB.String, DB.ForeignKey("ref_nomenclatures.bib_nomenclatures_types.mnemonique"), )
[docs] additional_attributes = DB.Column(JSONB)
[docs] id_widget = DB.Column( DB.Integer, DB.ForeignKey("gn_commons.bib_widgets.id_widget"), nullable=False )
[docs] id_list = DB.Column(DB.Integer)
[docs] exportable = DB.Column(DB.Boolean, default=True)
[docs] field_order = DB.Column(DB.Integer)
[docs] type_widget = DB.relationship("BibWidgets")
[docs] bib_nomenclature_type = DB.relationship("BibNomenclaturesTypes")
additional_attributes = DB.Column(JSONB)
[docs] multiselect = DB.Column(DB.Boolean)
[docs] api = DB.Column(DB.String)
[docs] default_value = DB.Column(DB.String)
[docs] modules = DB.relationship( "TModules", secondary=cor_field_module, )
[docs] objects = DB.relationship(PermObject, secondary=cor_field_object)
[docs] datasets = DB.relationship( TDatasets, secondary=cor_field_dataset, back_populates="additional_fields" )
[docs] def __str__(self): return self.field_label