from geonature.utils.env import db, ma
from geonature.utils.config import config
from geonature.core.gn_commons.schemas import ModuleSchema, MediaSchema, TValidationSchema
from geonature.core.gn_synthese.models import (
BibReportsTypes,
TReport,
TSources,
Synthese,
VSyntheseForWebApp,
)
from geonature.core.gn_synthese.synthese_config import MANDATORY_COLUMNS
from pypn_habref_api.schemas import HabrefSchema
from pypnusershub.schemas import UserSchema
from pypnnomenclature.utils import NomenclaturesConverter
from ref_geo.schemas import AreaSchema
from utils_flask_sqla.schema import SmartRelationshipsMixin
from utils_flask_sqla_geo.schema import GeoAlchemyAutoSchema, GeoModelConverter, GeometryField
[docs]
class ReportTypeSchema(ma.SQLAlchemyAutoSchema):
[docs]
class ReportSchema(SmartRelationshipsMixin, ma.SQLAlchemyAutoSchema):
[docs]
report_type = ma.Nested(ReportTypeSchema, dump_only=True)
[docs]
user = ma.Nested(UserSchema, dump_only=True)
[docs]
class SourceSchema(ma.SQLAlchemyAutoSchema):
[docs]
module_url = ma.String(dump_only=True)
[docs]
class SyntheseConverter(NomenclaturesConverter, GeoModelConverter):
pass
[docs]
class SyntheseSchema(SmartRelationshipsMixin, GeoAlchemyAutoSchema):
[docs]
the_geom_4326 = ma.auto_field(metadata={"exclude": True})
[docs]
the_geom_authorized = GeometryField(metadata={"exclude": True}, dump_only=True)
[docs]
source = ma.Nested(SourceSchema, dump_only=True)
[docs]
module = ma.Nested(ModuleSchema, dump_only=True)
[docs]
dataset = ma.Nested("DatasetSchema", dump_only=True)
[docs]
habitat = ma.Nested(HabrefSchema, dump_only=True)
[docs]
digitiser = ma.Nested(UserSchema, dump_only=True)
[docs]
cor_observers = ma.Nested(UserSchema, many=True, dump_only=True)
[docs]
areas = ma.Nested(AreaSchema, many=True, dump_only=True)
[docs]
area_attachment = ma.Nested(AreaSchema, dump_only=True)
[docs]
validations = ma.Nested(TValidationSchema, many=True, dump_only=True)
[docs]
last_validation = ma.Nested(TValidationSchema, dump_only=True)
[docs]
reports = ma.Nested(ReportSchema, many=True)
# Missing nested schemas: taxref