예제 #1
0
class User(UserMixin, db.Model):
    userId = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), index=True, unique=True)
    email= db.Column(db.String(128), index=True, unique=True)
    password_hash=db.Column(db.String(128))

    def __repr__(self): ##user for debugging purposes
        return '< User {}>'.format(self.username)

    def set_password(self, password):
        self.password_hash = generate_password_hash(password)

    def check_password(self, password):
        return check_password_hash(self.password_hash, password)
  
    def get_id(self):
        return (self.userId)
예제 #2
0
class User(db.Model):
    __tablename = 'users'
    id = db.Column(db.Integer, primary_key=True, index=True)
    username = db.Column(db.String(64), unique=True)
    role_id = db.Column(db.Integer, db.ForeignKey('roles.id'))

    def __repr__(self):
        return '<User %r>' % self.username
예제 #3
0
class User(db.Model):
    __table__name = "users"

    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True, nullable=False)
    password = db.Column(db.String(20), unique=True)
    name = db.Column(db.String(80), unique=True)
    email = db.Column(db.String(120), unique=True, nullable=False)

    def __init__(self, username, password, name, email):
        self.username = username
        self.password = password
        self.name = name
        self.email = email

    def __repr__(self): #representação
        return "<User %r" % self.username
예제 #4
0
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    body = db.Column(db.String(140))
    timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow())
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))

    def __repr__(self):
        return '<Post {}>'.format(self.body)
예제 #5
0
class Role(db.Model):
    __tablename__ = 'roles'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), unique=True)
    users = db.relationship('User', backref='role')

    def __repr__(self):
        return '<Role %r>' % self.name
예제 #6
0
class Person(db.Model):

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(LENGTH_M))
    vorname = db.Column(db.String(LENGTH_M))
    ort = db.Column(db.String(LENGTH_M))
    wiki_url = db.Column(db.String(LENGTH_M))
    photo = db.Column(db.String(LENGTH_M))
    anwender = db.Column(db.String(LENGTH_S))
    zeit = db.Column(db.String(LENGTH_S))

    def __init__(
        self, name=None, forename=None, place=None, remark=None, wiki_url=None, photo=None, user=None, time=datetime.now()
    ):
        self.name = name
        self.vorname = forename
        self.ort = place
        self.bemerkung = remark
        self.wiki_url = wiki_url
        self.photo = photo
        self.anwender = user
        self.zeit = time

    def __repr__(self):
        return '<Person {} {} {} {} {} {}>'.format(
            self.id, self.name, self.vorname, self.ort, self.anwender, self.zeit
        )
예제 #7
0
class ManufStock(db.Model):
    mStockid=db.Column(db.Integer, primary_key=True)
    manufId=db.Column(db.Integer, db.ForeignKey(Manuf.manufId), unique=False)
    availMedId=db.Column(db.Integer, db.ForeignKey(MedStock.medId), unique=False)
    availMedName=db.Column(db.String(120), db.ForeignKey(MedStock.medName), unique=False)
    availManufQnty=db.Column(db.Integer)

    def __repr__(self):
        return '<ManufStock {}>'.format(self.availMedName)
예제 #8
0
class Family(db.Model):
    """
    用户关联的族群实例
    """
    __tablename__ = 'familyr'

    f_id = db.Column(db.Integer, primary_key=True, autoincrement=True, comment="族群号")
    f_member_num = db.Column(db.Integer, default=0, comment="族群人数")
    f_create_time = db.Column(db.DateTime, default=datetime.now, comment="创建时间")
    f_creator = db.Column(db.String(64), db.ForeignKey('user.u_email'), comment="族群的创建者的邮箱(id)")
    u_name = db.Column(db.String(32), db.ForeignKey('user.u_email'), comment="创建者昵称")

    def __init__(self, creator):
        self.f_creator = creator

    def save(self):
        db.session.add(self)
        db.session.commit()
예제 #9
0
class Article(db.Model):
    __tablename__ = "articls"

    articls_id = db.Column(db.INT, primary_key=True, autoincrement=True)
    articls_title = db.Column(db.String(300), unique=False)
    articls_desc = db.Column(db.String(64), nullable=True)
    articls_contents = db.Column(db.Text, unique=False)
    articls_posttime = db.Column(db.DateTime)
    articls_category = db.Column(db.String(99), unique=False, default=None)
    articls_headimg = db.Column(db.String(99), unique=False, default=None)
    articls_views = db.Column(db.INTEGER, default=0, comment='阅读数')
    articls_gives = db.Column(db.INTEGER, default=0, comment='点赞数')
    # user_id = db.Column(db.INTEGER, db.ForeignKey('admin_user.user_id'))  # 关联用户userID
    tag_id = db.Column(db.INTEGER, db.ForeignKey('tag.id'))  # 关联标签ID
    category_id = db.Column(db.INTEGER, db.ForeignKey('category.id'))  # 关联分类ID
    comment = db.relationship('Comment', backref='comment', lazy='dynamic')
    tag = db.relationship('Tag', backref='tag')
    category = db.relationship('Category', backref='status')
class Message(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    sender_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    recipient_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    body = db.Column(db.String(200))
    timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)

    def __repr__(self):
        return '<Message {}>'.format(self.body)
예제 #11
0
class Users(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    member = db.Column(db.Integer, db.ForeignKey("members.id"))
    password_hash = db.Column(db.String(128))
    admin = db.Column(db.Boolean, nullable=False)
    timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)

    def __repr__(self):
        return '<User {}>'.format(self.id)
예제 #12
0
class Contents(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    loc = db.Column(db.String(128), nullable=False)
    body_en = db.Column(db.Text)
    body_pl = db.Column(db.Text)
    timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)

    def __repr__(self):
        return '<Content {}>'.format(self.id)
예제 #13
0
class Post(db.Model):
    id= db.Column(db.Integer,primary_key=True)
    title = db.Column(db.String(100),nullable=False)
    date_posted= db.Column(db.DateTime,nullable=False,default=datetime.utcnow)
    content= db.Column(db.Text,nullable=False)
    user_id= db.Column(db.Integer , db.ForeignKey('user.id'),nullable=False)
    
    def __repr__(self):
        return "Post('{}','{}','{}')".format(self.title,self.date_posted,self.content[:100]) 
예제 #14
0
class Manuf(db.Model):
    manufId = db.Column(db.Integer, primary_key=True)
    manufName = db.Column(db.String(120), index=True, unique=True)

    #    availMedId=db.Column(db.Integer, db.ForeignKey('MedStock.medId'))
    #    availManufQnty=db.Column(db.Integer)

    def __repr__(self):
        return '<Manuf {}>'.format(self.manufName)
예제 #15
0
class Part(Base):
    __tablename__ = 'part'
    Part_Name = db.Column(db.String(32), unique=True)
    Part_Users = db.relationship("User", backref="user_part", lazy="dynamic")

    def __init__(self, partName):
        self.Part_Name = partName

    def __repr__(self):
        return f"part:{self.Part_Name}"
예제 #16
0
class Conversation(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(191))
    started_by = db.Column(db.Integer)
    started_with = db.Column(db.Integer)
    created_at = db.Column(db.DateTime(), default=datetime.utcnow())
    updated_at = db.Column(db.DateTime())
    messages = db.relationship('Message',
                               backref='conversation',
                               lazy='dynamic')
예제 #17
0
class Steps(Base):
    __tablename__ = 'steps'
    case_id = db.Column(db.Integer,
                        db.ForeignKey('uicase.id'),
                        nullable=True,
                        comment='所属用例')
    name = db.Column(db.String(200),
                     nullable=True,
                     unique=False,
                     comment="步骤名称")
    desc = db.Column(db.String(200), nullable=True, comment="步骤描述")
    is_method = db.Column(db.Integer, nullable=True, comment="方法")
    type = db.Column(db.String(32), nullable=True, comment="步骤类型")
    log = db.Column(db.String(100), nullable=True, comment="这步骤日志")
    locator = db.Column(db.String(100), nullable=True, comment="步骤元素")
    do = db.Column(db.String(32), nullable=True, comment='步驟操作')
    value = db.Column(db.TEXT, nullable=True, comment="请求数据")
    variable = db.Column(db.TEXT, nullable=True, comment="变量名称")
    validate = db.Column(db.TEXT, nullable=True, comment="认证")
    pic = db.Column(db.String(100), nullable=True, comment="截圖地址")
    data = db.Column(db.String(100), nullable=True, comment="验证数据")

    def __init__(self,
                 name=None,
                 desc=None,
                 is_method=None,
                 type=None,
                 locator=None,
                 do=None,
                 value=None,
                 variable=None,
                 validate=None):
        self.name = name
        self.desc = desc
        self.is_method = is_method
        self.type = type
        self.locator = locator
        if do:
            do = self.assertDo(do)
        else:
            do = do
        self.do = do
        self.value = value
        self.variable = variable
        self.validate = validate

    def assertDo(self, do: str):
        if do not in DO:
            handelAbort(f"Parameter:{do} not support")
        return do

    def __repr__(self):
        return f"name:{self.name}"
예제 #18
0
class Suite(Base):
    """
    与用例多对多关系
    """
    __tablename__ = 'suite'
    name = db.Column(db.String(32))
    includes = db.Column(db.TEXT, comment="套件里的用例")

    def __repr__(self):
        return f"name:{self.name}"
예제 #19
0
class Dieta(db.Model):
    __tablename__ = 'dieta'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    descricao = db.Column(db.String(50), nullable=False, unique=True)
    data = db.Column(db.Date, nullable=False, default=datetime.datetime.now())
    mesano = db.Column(db.String(8), nullable=False)
    totalcarbo = db.Column(db.NUMERIC(precision=8, asdecimal=False, scale=3))
    totalproteina = db.Column(db.NUMERIC(precision=8, asdecimal=False,
                                         scale=3))
    totalgordura = db.Column(db.NUMERIC(precision=8, asdecimal=False, scale=3))
    totalfibras = db.Column(db.NUMERIC(precision=8, asdecimal=False, scale=3))
    totalsodio = db.Column(db.NUMERIC(precision=8, asdecimal=False, scale=3))
    totalcalorias = db.Column(db.NUMERIC(precision=8, asdecimal=False,
                                         scale=3))
    idrefeicao = db.Column(db.Integer, db.ForeignKey('refeicao.id'))
    idmetaatleta = db.Column(db.Integer, db.ForeignKey('metaatleta.id'))
    create_on = db.Column(db.DateTime, default=datetime.datetime.now())
    dieta_refeicao = db.relationship('Refeicao')
    metaatleta = db.relationship('Metaatleta')
예제 #20
0
class Product(db.Model):

    product_id = db.Column(db.Integer, primary_key=True)
    product_name = db.Column(db.String(20), unique=True, nullable=False)
    product_qty = db.Column(db.Integer, nullable=False)

    def __init__(self, product_name, product_qty):
        #self.product_id=product_id
        self.product_name = product_name
        self.product_qty = product_qty
예제 #21
0
class beatcomplaint(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    beat = db.Column('beat', db.String(100), unique=False, nullable=False)
    complaint_date = db.Column('complaint_date',
                               db.String(100),
                               unique=False,
                               nullable=False)
    current_category = db.Column('current_category',
                                 db.String(100),
                                 unique=False,
                                 nullable=True)
    log_no = db.Column('log_no', db.String(100), unique=False, nullable=True)
    race_of_complainant = db.Column('race_of_complainant',
                                    db.String(100),
                                    unique=False,
                                    nullable=True)

    def __repr__(self):
        return '<Track %r>' % self.title
예제 #22
0
class OrderMedFor(db.Model):
    orderId= db.Column(db.Integer, primary_key=True)
    medId= db.Column(db.Integer, db.ForeignKey(MedStock.medId))
    medName= db.Column(db.String(120), db.ForeignKey(MedStock.medName)) 
    toManufId=db.Column(db.Integer,  db.ForeignKey(Manuf.manufId))
    wantQnty= db.Column(db.Integer)
    byDate=db.Column(db.Date )

    def __repr__(self):
        return '<OrderMedFor {}>'.format(self.medName)
예제 #23
0
class Shops(db.Model):
    __tablename__ = "shops"
    id = db.Column(db.Integer, primary_key=True, nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
    shop_name = db.Column(db.String(64), nullable=False, unique=True)

    products = db.relationship('Products',
                               backref='store',
                               lazy='dynamic',
                               cascade="save-update, merge, delete")
    orders = db.relationship('Orders',
                             backref='store',
                             lazy='dynamic',
                             cascade="save-update, merge, delete")

    def __repr__(self):
        return '<Shop {}>'.format(self.shop_name)

    def owned_items(self):
        product_ids = [
            product.id
            for product in Products.query.filter_by(shop_id=self.id).all()
        ]
        order_ids = [
            order.id
            for order in Orders.query.filter_by(shop_id=self.id).all()
        ]
        p_items = LineItems.query.filter(
            LineItems.product_id.in_(product_ids)).all()
        items = LineItems.query.filter(LineItems.order_id.in_(order_ids)).all()

        for i in p_items:
            is_duplicated = False
            for _i in items:
                if i.id == _i.id:
                    is_duplicated = True
                    break
            if not is_duplicated:
                items.append(i)

        return items

    def owned_item_ids(self):
        return [item.id for item in self.owned_items()]

    @staticmethod
    def create_shop(name, owner):
        shop = Shops.query.filter(Shops.shop_name == name).first()
        if shop is not None:
            return False

        shop = Shops(shop_name=name, user_id=owner.id)
        db.session.add(shop)
        db.session.commit()
        return shop.id
예제 #24
0
class Metaatleta(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    descricao = db.Column(db.String(50), nullable=False)
    create_on = db.Column(db.DateTime, default=datetime.datetime.now())
    pesoinicial = db.Column(db.NUMERIC(precision=8, asdecimal=False, scale=2))
    pesofinal = db.Column(db.NUMERIC(precision=8, asdecimal=False, scale=2))
    percentual_gordura = db.Column(
        db.NUMERIC(precision=8, asdecimal=False, scale=2))
    nivelatividade = db.Column(
        db.NUMERIC(precision=8, asdecimal=False, scale=2))
    # 0-Harris Benedict Original 1-Harris Benedict Revisada 2-Mifflin St Jeor 3-Katch-McArdle
    frmharrisbenedictoriginal = db.Column(db.String(1), nullable=False)
    frmharrisbenedictrevisada = db.Column(db.String(1), nullable=False)
    frmmifflin = db.Column(db.String(1), nullable=False)
    frmkatch = db.Column(db.String(1), nullable=False)
    valtmb = db.Column(db.NUMERIC(precision=8, asdecimal=False, scale=0))
    valgcd = db.Column(db.NUMERIC(precision=8, asdecimal=False, scale=0))
    # P-perda de peso G-ganho de peso
    tipometa = db.Column(db.String(1), nullable=False)
    valtotkclmeta = db.Column(db.NUMERIC(precision=8, asdecimal=False,
                                         scale=0))
    valtotkclexercicio = db.Column(
        db.NUMERIC(precision=8, asdecimal=False, scale=0))
    valalvocalorico = db.Column(
        db.NUMERIC(precision=8, asdecimal=False, scale=0))

    # Proteina
    percproteina = db.Column(db.NUMERIC(precision=8, asdecimal=False, scale=2))
    valkcalproteina = db.Column(
        db.NUMERIC(precision=8, asdecimal=False, scale=2))
    valgramasproteina = db.Column(
        db.NUMERIC(precision=8, asdecimal=False, scale=2))
    valgrkgproteina = db.Column(
        db.NUMERIC(precision=8, asdecimal=False, scale=2))
    # Carboidrato
    perccarb = db.Column(db.NUMERIC(precision=8, asdecimal=False, scale=2))
    valkcalcarb = db.Column(db.NUMERIC(precision=8, asdecimal=False, scale=2))
    valgramascarbo = db.Column(
        db.NUMERIC(precision=8, asdecimal=False, scale=2))
    valgrkgcarbo = db.Column(db.NUMERIC(precision=8, asdecimal=False, scale=2))
    # Gordura
    percfat = db.Column(db.NUMERIC(precision=8, asdecimal=False, scale=2))
    valkcalfat = db.Column(db.NUMERIC(precision=8, asdecimal=False, scale=2))
    valgramasgordura = db.Column(
        db.NUMERIC(precision=8, asdecimal=False, scale=2))
    valgrkggordura = db.Column(
        db.NUMERIC(precision=8, asdecimal=False, scale=2))
    # A-Aberto F-Fechada
    status = db.Column(db.String(1), nullable=False)
    idatleta = db.Column(db.Integer,
                         db.ForeignKey('atleta.id', ondelete='CASCADE'))
    atleta = db.relationship("Atleta", back_populates="metaatleta")
    totaldiasprevisto = db.Column(db.Integer)
    dataprevisaofinal = db.Column(db.DateTime)
    datafinalizada = db.Column(db.DateTime)
    pesofinalizado = db.Column(
        db.NUMERIC(precision=8, asdecimal=False, scale=2))
예제 #25
0
class BoughtBy(db.Model):
    cusId= db.Column(db.Integer, primary_key=True)
    cusName= db.Column(db.String(120), index=True, unique=True)
    medId= db.Column(db.Integer, db.ForeignKey(MedStock.medId))
    buyQnty= db.Column(db.Integer)
    date= db.Column(db.Date, default=date.today())
    CO1=db.Column(db.Integer,  db.ForeignKey(MedStock.CO1))
    totCost=buyQnty*CO1

    def __repr__(self):
        return '<BoughtBy {}>'.format(self.cusName)
예제 #26
0
class Report(Base):
    __tablename__ = "report"
    name = db.Column(db.String(200), unique=True, comment="测试报告")
    result = db.Column(db.Boolean, default=False, comment="测试结果")
    count = db.Column(db.Integer, nullable=True, comment="用例数")
    success = db.Column(db.Integer, nullable=True, comment="成功数")
    html = db.Column(db.TEXT, default="", comment="报告html")
    summary = db.Column(db.TEXT, default="", comment="报告详情")

    def __repr__(self):
        return f"name:{self.name}"
예제 #27
0
class User(db.Model):
    """
    用户类
    """
    __tablename__ = 'user'
    u_email = db.Column(db.String(64), primary_key=True, unique=True, comment="邮箱就是id,不可更换")
    u_name = db.Column(db.String(32), comment="昵称,不可更改")
    u_qq = db.Column(db.String(32), comment="QQ")
    u_weixin = db.Column(db.String(32), comment="微信")
    u_create_time = db.Column(db.DateTime, default=datetime.now, comment="创建时间")
    u_family_id = db.Column(db.Integer, default=None, comment="所属的族群号")
    u_key_word_list = db.Column(db.String(128), comment="特征词")

    def __init__(self, name, email):
        self.u_email = email
        self.u_name = name

    def save(self):
        db.session.add(self)
        db.session.commit()
예제 #28
0
class Links(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    public_id = db.Column(db.String(256), unique=True, nullable=False)
    access = db.Column(db.String(20), default="private")
    title = db.Column(db.String(128), nullable=False)
    description = db.Column(db.Text, nullable=False)
    link = db.Column(db.String(128), nullable=False)

    def __repr__(self):
        return f'{self.title} {self.public_id} {self.link}'

    def get_links():
        try:
            links = Links.query.all()
        except Exception as e:
            raise e

        return links

    def get_link(link_id):

        try:
            link = Links.query.filter_by(public_id=link_id).first()
        except Exception as e:
            raise e

        return link

    def serializer(self):
        return {"public_id": self.public_id, "title": self.title, "access": self.access, "description": self.description, "link": self.link}

    def add_db(self):
        try:
            db.create_all()

            db.session.add(self)
            db.session.commit()
        except Exception as e:
            raise e

        return "success"
예제 #29
0
class KopieB(db.Model):

    id = db.Column(db.Integer, primary_key=True)
    id_brief = db.Column(db.Integer, index=True)
    standort = db.Column(db.String(LENGTH_M))
    signatur = db.Column(db.String(LENGTH_M))
    bemerkung = db.Column(db.String(LENGTH_B))
    anwender = db.Column(db.String(LENGTH_S))
    zeit = db.Column(db.String(LENGTH_S))

    def __init__(self, id_brief=None, location=None, signature=None, remark=None, user=None, time=datetime.now()):
        self.id_brief = id_brief
        self.standort = location
        self.signatur = signature
        self.bemerkung = remark
        self.anwender = user
        self.zeit = time

    def __repr__(self):
        return '<Kopie {} {} {} {} {} {} {}>'.format(
            self.id, self.id_brief, self.standort, self.signatur, self.bemerkung, self.anwender, self.zeit)
예제 #30
0
class Absender(db.Model):

    id = db.Column(db.Integer, primary_key=True)
    id_brief = db.Column(db.Integer, index=True)
    id_person = db.Column(db.Integer)
    nicht_verifiziert = db.Column(db.Boolean)
    bemerkung = db.Column(db.String(LENGTH_B))
    anwender = db.Column(db.String(LENGTH_S))
    zeit = db.Column(db.String(LENGTH_S))

    def __init__(self, id_brief=None, id_person=None, not_verified=None, remark=None, user=None, time=datetime.now()):
        self.id_brief = id_brief
        self.id_person = id_person
        self.nicht_verifiziert = not_verified
        self.bemerkung = remark
        self.anwender = user
        self.zeit = time

    def __repr__(self):
        return '<Absender {} {} {} {} {} {} {}>'.format(
            self.id, self.id_brief, self.id_person, self.nicht_verifiziert, self.bemerkung, self.anwender, self.zeit)