Ejemplo n.º 1
0
class ProgramsModel(TimestampMixinModel, db.Model):
    """Table des Programmes de GeoNature-citizen"""

    __tablename__ = "t_programs"
    __table_args__ = {"schema": "gnc_core"}
    id_program = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(50), nullable=False)
    short_desc = db.Column(db.String(200), nullable=False)
    long_desc = db.Column(db.Text(), nullable=False)
    image = db.Column(db.String(250))
    logo = db.Column(db.String(250))
    module = db.Column(
        db.Integer,
        ForeignKey(ModulesModel.id_module),
        nullable=False,
        default=1,
    )
    taxonomy_list = db.Column(
        db.Integer, 
        #ForeignKey(BibListes.id_liste), 
        nullable=True
    )
    is_active = db.Column(
        db.Boolean(), server_default=expression.true(), default=True
    )
    geom = db.Column(Geometry("GEOMETRY", 4326))

    def get_geofeature(self, recursif=True, columns=None):
        return self.as_geofeature(
            "geom", "id_program", recursif, columns=columns
        )
Ejemplo n.º 2
0
class ModulesModel(TimestampMixinModel, db.Model):
    """Table des modules de GeoNature-citizen"""

    __tablename__ = "t_modules"
    __table_args__ = {"schema": "gnc_core"}
    id_module = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), nullable=False)
    label = db.Column(db.String(50), nullable=False)
    desc = db.Column(db.String(200))
    icon = db.Column(db.String(250))
    on_sidebar = db.Column(db.Boolean(), default=False)
Ejemplo n.º 3
0
class UserRightsModel(TimestampMixinModel, db.Model):  # type: ignore
    """Table de gestion des droits des utilisateurs de GeoNature-citizen"""

    __tablename__ = "t_users_rights"
    __table_args__ = {"schema": "gnc_core"}
    id_user_right = db.Column(db.Integer, primary_key=True)
    id_user = db.Column(db.Integer,
                        db.ForeignKey(UserModel.id_user),
                        nullable=False)
    id_module = db.Column(db.Integer,
                          db.ForeignKey(ModulesModel.id_module),
                          nullable=True)
    id_module = db.Column(db.Integer,
                          db.ForeignKey(ProgramsModel.id_program),
                          nullable=True)
    right = db.Column(db.String(150), nullable=False)
    create = db.Column(db.Boolean(), default=False)
    read = db.Column(db.Boolean(), default=False)
    update = db.Column(db.Boolean(), default=False)
    delete = db.Column(db.Boolean(), default=False)
Ejemplo n.º 4
0
class ProgramsModel(TimestampMixinModel, db.Model):
    """Table des Programmes de GeoNature-citizen"""

    __tablename__ = "t_programs"
    __table_args__ = {"schema": "gnc_core"}
    id_program = db.Column(db.Integer, primary_key=True)
    unique_id_program = db.Column(UUID(as_uuid=True),
                                  default=uuid.uuid4,
                                  unique=True,
                                  nullable=False)
    id_project = db.Column(db.Integer,
                           db.ForeignKey(ProjectModel.id_project),
                           nullable=False)
    title = db.Column(db.String(50), nullable=False)
    short_desc = db.Column(db.String(200), nullable=False)
    long_desc = db.Column(db.Text(), nullable=False)
    form_message = db.Column(db.String(500))
    image = db.Column(db.String(250))
    logo = db.Column(db.String(250))
    id_module = db.Column(
        db.Integer,
        ForeignKey(TModules.id_module),
        nullable=False,
        default=1,
    )
    module = relationship("TModules")
    taxonomy_list = db.Column(db.Integer, nullable=True)
    is_active = db.Column(db.Boolean(),
                          server_default=expression.true(),
                          default=True)
    id_geom = db.Column(db.Integer,
                        db.ForeignKey(GeometryModel.id_geom),
                        nullable=False)
    id_form = db.Column(db.Integer,
                        db.ForeignKey(CustomFormModel.id_form),
                        nullable=True)
    custom_form = relationship("CustomFormModel")
    geometry = relationship("GeometryModel")
    project = relationship("ProjectModel")

    def get_geofeature(self, recursif=True, columns=None):
        geometry = to_shape(self.geometry.geom)
        feature = Feature(
            id=self.id_program,
            geometry=geometry,
            properties=self.as_dict(True, exclude=["t_obstax"]),
        )
        return feature

    def __repr__(self):
        return self.title