Пример #1
0
        return f'{self.name}'


@event.listens_for(User.password, 'set', retval=True)
def hash_user_password(target, value, old_value, initiator):
    """
    Listener for hashing new password
    """
    if value != old_value:
        return generate_password_hash(value)
    else:
        return old_value


meals_orders = db.Table(
    'meals_orders',
    db.Column('order_id', db.Integer, db.ForeignKey('orders.id')),
    db.Column('meal_id', db.Integer, db.ForeignKey('meals.id')))


class Meal(db.Model):
    __tablename__ = 'meals'
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(80), unique=True, nullable=False)
    price = db.Column(db.Integer, nullable=False)
    description = db.Column(db.String(200), nullable=False)
    picture = db.Column(db.String(80), nullable=False)
    category_id = db.Column(db.Integer, db.ForeignKey("categories.id"))
    category = db.relationship("Category",
                               back_populates="meals",
                               lazy='joined')
    orders = db.relationship('Order',
Пример #2
0
    floor = db.Column(db.Integer)
    no = db.Column(db.Integer)
    capacity = db.Column(db.Integer)
    name = db.Column(db.String(80), nullable=False)
    detail = db.Column(db.String(80), nullable=False)
    available = db.Column(db.Boolean, default=True)
    orders = db.relationship('Order',
                             lazy='select',
                             backref=db.backref('room', lazy=True))


members = db.Table(
    'meeting_members',
    db.Column('order_id',
              db.UUID(as_uuid=True),
              db.ForeignKey('room_booking_order.id'),
              primary_key=True),
    db.Column('member_id',
              db.String,
              db.ForeignKey('user.id'),
              primary_key=True))


class Order(db.Model, CRUDMixin, TimeMixin):
    __tablename__ = 'room_booking_order'
    id = db.Column(db.UUID(as_uuid=True), default=uuid.uuid4, primary_key=True)
    user_id = db.Column(db.String, db.ForeignKey('user.id'))
    room_id = db.Column(db.UUID, db.ForeignKey('room.id'))
    contact = db.Column(db.String)
    teacher = db.Column(db.String)
    date = db.Column(db.DateTime)
    start = db.Column(db.Integer)
Пример #3
0
from geoalchemy2 import Geometry
from sqlalchemy import ForeignKey
from sqlalchemy.dialects.postgresql import JSON, JSONB

from application.extensions import  db


organisation_feature = db.Table('organisation_feature',
                                db.Column('organisation', db.String(64), db.ForeignKey('organisation.organisation'),
                                          primary_key=True),
                                db.Column('feature', db.String(256), db.ForeignKey('feature.feature'),
                                          primary_key=True),
                                )

class Category(db.Model):
    """
    actually our wiki, containing concepts and tags, linked to by markdown
    """
    category = db.Column(db.String(64), primary_key=True)        # Local Authority, Planning Authority, etc
    text = db.Column(db.Text)

    publications = db.relationship('Publication', backref='category', lazy=True)
    organisations  = db.relationship('Organisation', backref='category', lazy=True)


class Licence(db.Model):
    licence = db.Column(db.String(256), primary_key=True)
    name = db.Column(db.String(256))
    url = db.Column(db.Text)
    text = db.Column(db.Text)
Пример #4
0
                       _external=_external)

    @cached_property
    def url(self):
        return self._url()

    @cached_property
    def permalink(self):
        return self._url(True)


post_tags = db.Table(
    "post_tags", db.Model.metadata,
    db.Column("post_id",
              db.Integer,
              db.ForeignKey('posts.id', ondelete='CASCADE'),
              primary_key=True),
    db.Column("tag_id",
              db.Integer,
              db.ForeignKey('tags.id', ondelete='CASCADE'),
              primary_key=True))


class TagQuery(BaseQuery):
    def cloud(self):

        tags = self.filter(Tag.num_posts > 0).all()

        if not tags:
            return []

        max_posts = max(t.num_posts for t in tags)
Пример #5
0
#     """
#     归经
#     """
#     __tablename__ = 'tb_herb_meridian'
#     id = Column(Integer, autoincrement=True, primary_key=True)
#     tb_herb = relationship('Herb')
#     bin_hid = Column(String(32),
#                      ForeignKey('tb_herb.bin_hid', ondelete='CASCADE'))
#     type_id = Column(Integer)
#     s_meridian = Column(String(20), comment=u"归经", nullable=False)  # 归经

herb_property_table = db.Table(
    "tb_rel_herb_property",
    db.metadata,
    db.Column(
        "herb_id", db.String(36), db.ForeignKey("tb_herb.bin_hid", ondelete="CASCADE")
    ),
    db.Column(
        "property_id", BigInteger, db.ForeignKey("tb_dic_data.id", ondelete="CASCADE")
    ),
)


class HerbAlias(BaseModel):
    """
    别名
    """

    __tablename__ = "tb_herb_alias"
    id = Column(Integer, autoincrement=True, primary_key=True)
    # tb_herb = relationship('Herb')
    bin_hid = Column(String(32), ForeignKey("tb_herb.bin_hid", ondelete="CASCADE"))
Пример #6
0
# coding:utf-8

from flask_security.models import fsqla_v2 as fsqla

from application.extensions import db

role_resource_table = db.Table(
    "tb_rel_role_resource",
    db.metadata,
    db.Column("role_id", db.Integer, db.ForeignKey("role.id")),
    db.Column("resource_id", db.String(36), db.ForeignKey("resource.id")),
)


class Role(db.Model, fsqla.FsRoleMixin):
    def get_id(self):
        return str(self.id)

    def to_dict_simple(self):
        return dict([(k, getattr(self, k)) for k in self.__dict__.keys()
                     if not k.startswith("_")])

    @staticmethod
    def data_table_fields() -> list:
        """
        数据表的字段列表
        Returns:

        """
        return ["id", "update_datetime", "s_name", "description"]
Пример #7
0
@contact: [email protected]
@software: Pycharm
@file: related_tables.py
@time: 2021/1/29 21:37
@desc:
"""
from application.extensions import db

target_gene_table = db.Table(
    "tb_rel_target_gene",
    db.metadata,
    db.Column(
        "target_id",
        db.String(36),
        db.ForeignKey("tb_target.bin_id", ondelete="CASCADE"),
    ),
    db.Column(
        "ingredient_id",
        db.String(36),
        db.ForeignKey("tb_ingredient.bin_id", ondelete="CASCADE"),
    ),
    db.Column("s_name", db.String(100), comment="关系名", default="TargetGene"),
)

herb_tcm_table = db.Table(
    "tb_rel_herb_tcm",
    db.metadata,
    db.Column("herb_id", db.String(36),
              db.ForeignKey("tb_herb.bin_hid", ondelete="CASCADE")),
    db.Column(
        "tcm_id",