Beispiel #1
0
class Task(db.Model):
    __tablename__ = "tasks"
    id = db.Column(
        INTEGER(unsigned=True),
        primary_key=True,
        autoincrement=True,
    )
    quest_id = db.Column(
        INTEGER(unsigned=True),
        db.ForeignKey("quests.id", ondelete="cascade", onupdate="cascade"),
        nullable=False,
    )
    name = db.Column(db.String(255), nullable=False)
    description = db.Column(db.String(5000))
    start = db.Column(db.DateTime)
    done = db.Column(db.Boolean, default=False)
    created_at = db.Column(
        db.DateTime,
        server_default=db.func.current_timestamp(),
        server_onupdate=db.func.current_timestamp(),
        nullable=False,
    )
    updated_at = db.Column(
        db.DateTime,
        server_default=db.func.current_timestamp(),
        server_onupdate=db.func.current_timestamp(),
        nullable=False,
    )
    subtasks = db.relationship("Subtask", backref="task", cascade="all")

    def __init__(self, quest_id, name, description=None):
        self.quest_id = quest_id
        self.name = name
        self.description = description

    def to_dict(self):
        return dict(
            id=self.id,
            name=self.name,
            description="" if self.description is None else self.description,
            done=self.done,
            subtasks=[subtask.to_dict() for subtask in self.subtasks],
            start=self.start,
        )
Beispiel #2
0
class Role(db.Model):
    __tablename__ = 'roles'
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(50), unique=True)

    def __init__(self, name):
        self.name = name

    def __repr__(self):
        return self.name
Beispiel #3
0
class Task(db.Model):
    """Model for storing tasks
    """

    __tablename__ = "tasks"

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    type = db.Column(db.Integer, nullable=False)
    url = db.Column(db.String(512), nullable=False)
    status = db.Column(db.Boolean, nullable=False)
Beispiel #4
0
class Assignee_report(db.Model,base.Base):
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('User.id'))
    assignee_performance = db.Column(db.String(100))

    User = relationship("User", backref=backref("User_Assignee_report", uselist=False))

    def __init__(self,user_id,assignee_performance):
        self.user_id = user_id
        self.assignee_performance = assignee_performance
Beispiel #5
0
class Words(db.Model):
    __tablename__ = 'words'
    __table_args__ = (
        db.UniqueConstraint("view_id", "word"),
    )
    id = db.Column(db.Integer, primary_key=True)
    word = db.Column(db.String(255), nullable=False)
    translation = db.Column(db.String(255), nullable=False)
    url = db.Column(db.String(511), nullable=False)
    created_on = db.Column(db.DateTime(), default=datetime.utcnow)

    category_id = db.Column(db.Integer, db.ForeignKey('category.id', ondelete='CASCADE'), nullable=False)
    category = db.relationship('Category',  backref=db.backref('words', lazy=True))

    view_id = db.Column(db.Integer, db.ForeignKey('view.id', ondelete='CASCADE'), nullable=False)
    view = db.relationship('View',  backref=db.backref('views', lazy=True))

    def __repr__(self):
        return '<Words %r>' % self.word
Beispiel #6
0
class Office(db.Model):
    __tablename__ = "offices"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.Integer, unique=True)
    timestamp = db.Column(db.DateTime(), index=True, default=datetime.utcnow)
    prefix = db.Column(db.String(2))

    def __init__(self, name, prefix):
        self.name = name
        self.prefix = prefix
class Log(db.Model, TimestampMixin):
    _id = db.Column('id', db.Integer, primary_key=True,
                    autoincrement=True)

    logtype = db.Column(db.String(20), nullable=False, default="")
    content = db.Column(db.Text, nullable=False, default="")

    def __repr__(self):
        return '<%r %r %d>' % (self.__class__.__name__,
                               self.log_type, self._id)
Beispiel #8
0
class Coupon(BaseModel, db.Model):
    __bind_key__ = 'theonestore'
    __tablename__ = 'coupon'

    coupon_id = db.Column(db.Integer, primary_key=True)
    uid = db.Column(db.Integer, default=0)
    cb_id = db.Column(db.Integer, default=0)
    coupon_name = db.Column(db.String(255), default='')
    begin_time = db.Column(db.Integer, default=0)
    end_time = db.Column(db.Integer, default=0)
    is_valid = db.Column(db.Integer, default=0)
    limit_amount = db.Column(db.Float, default=99999.00)
    coupon_amount = db.Column(db.Float, default=0.00)
    limit_goods = db.Column(db.String(255), default='')
    limit_goods_name = db.Column(db.String(255), default='')
    coupon_from = db.Column(db.String(16), default='')
    order_id = db.Column(db.Integer, default=0)
    use_time = db.Column(db.Integer, default=0)
    add_time = db.Column(db.Integer, default=0)
Beispiel #9
0
class Task(db.Model):
	__tablename__ = 'tasks'

	id = db.Column(db.Integer, primary_key=True)
	name = db.Column(db.String(45), nullable=False)
	description = db.Column(db.Text)
	user_id = db.Column(db.Integer, db.ForeignKey(User.id))

	def __str__(self):
		return self.name
Beispiel #10
0
class Activity(Base):

    subject = db.Column(db.String(100), nullable=False)
    detail = db.Column(db.String)

    contact_id = db.Column(db.Integer, db.ForeignKey('contact.id'))
    org_id = db.Column(db.Integer,
                       db.ForeignKey('organisation.id', ondelete='cascade'))
    ticket_id = db.Column(db.Integer,
                          db.ForeignKey('ticket.id', ondelete='cascade'))
Beispiel #11
0
class City(db.Model):
    #__tablename__ = 'cities'
    __tablename__ = 'city'

    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(100))
    id_area = db.Column(db.Integer, ForeignKey('area.id'))

    def __str__(self):
        return self.name
Beispiel #12
0
class URLLog(db.Model):
    __tablename__ = 'url_logs'

    id = db.Column(db.BigInteger, primary_key=True, index=True)
    url_id = db.Column(db.BigInteger,
                       db.ForeignKey('urls.id'),
                       nullable=False,
                       index=True)
    timestamp = db.Column(db.DateTime, nullable=False, index=True)
    os = db.Column(db.String(length=30), nullable=True, index=True)
    platform = db.Column(db.String(length=30), nullable=True, index=True)
    browser = db.Column(db.String(length=30), nullable=True, index=True)

    def __init__(self, url_id, os, platform, browser):
        self.url_id = url_id
        self.os = os
        self.platform = platform
        self.browser = browser
        self.timestamp = datetime.utcnow()
Beispiel #13
0
class Attachment(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    path = db.Column(db.String(300))
    post_id = db.Column(db.Integer, db.ForeignKey('post.id'), nullable=False)

    def __init__(self, *args, **kwargs):
        super(Attachment, self).__init__(*args, **kwargs)

    def __repr__(self):
        return '{}:{}:{}'.format(self.id, self.path, self.post_id)
Beispiel #14
0
class Task(db.Model):
    __tablename__ = "tasks"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(300))
    timestamp = db.Column(db.DateTime(), index=True, default=datetime.utcnow)
    office_id = db.Column(db.Integer, db.ForeignKey('offices.id'))

    def __init__(self, name, office_id):
        self.name = name
        self.office_id = office_id
class User(BaseModel, UserMixin):
    __tablename__ = 'user'
    username = db.Column(db.String(255), unique=True, index=True)
    password = db.Column(db.String(255))
    active = db.Column(db.Boolean(), index=True)
    confirmed_at = db.Column(db.DateTime())
    last_login_at = db.Column(db.DateTime())
    current_login_at = db.Column(db.DateTime())
    last_login_ip = db.Column(db.String(63))
    current_login_ip = db.Column(db.String(63))
    login_count = db.Column(db.Integer)
    groups = db.relationship('Group',
                             secondary=groups_users,
                             backref=db.backref('users', lazy='dynamic'))
    roles = db.relationship('Role',
                            secondary=roles_users,
                            backref=db.backref('users', lazy='dynamic'))

    def __repr__(self):
        return '<User %r>' % self.username
Beispiel #16
0
class Role(SurrogatePK, Model):
    __tablename__ = 'roles'
    name = Column(db.String(80), unique=True, nullable=False)
    user_id = ReferenceCol('users', nullable=True)
    user = relationship('User', backref='roles')

    def __init__(self, name, **kwargs):
        db.Model.__init__(self, name=name, **kwargs)

    def __repr__(self):
        return '<Role({name})>'.format(name=self.name)
Beispiel #17
0
class Airport(db.Model):
    __tablename__ = 'airports'
    airport_id = db.Column(db.Integer, autoincrement=True, primary_key=True)
    name = db.Column(db.String(500), nullable=False)
    flights = db.relationship('Flight')

    def __repr__(self):
        return {'arrive_location': self.name}

    def make_json_serializable(self):
        return {'arrive_location': self.name}
Beispiel #18
0
class StudyFeedback(BaseModel, db.Model):
    __tablename__ = 'study_feedback'
    student_id = db.Column(db.Integer, db.ForeignKey('student_info.id'))
    chinese_name = db.Column(db.String(20))
    study_date = db.Column(db.Date)
    class_time = db.Column(db.String(30))
    study_time = db.Column(db.String(30))
    course_name = db.Column(db.String(20))
    section = db.Column(db.String(20))
    contents = db.Column(db.String(50))
    homework = db.Column(db.String(75))
    feedback = db.Column(db.String(125))
    update_time = db.Column(db.DateTime, default=datetime.now)
Beispiel #19
0
class Pessoa(db.Model):
    __tablename__ = "pessoa"
    id = db.Column(db.Integer, primary_key=True)
    nome = db.Column(db.String(50))
    data_nascimento = db.Column(db.Date)

    def __init__(self, nome=None, data_nascimento=None):
        self.nome = nome
        self.data_nascimento = data_nascimento

    usuarios = db.relationship("Usuario", backref="pessoa", lazy=True)
Beispiel #20
0
class BugFix(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(1023))
    text = db.Column(db.Text)
    date = db.Column(db.Date)
    status = db.Column(db.String(1))
    timefj = db.Column(db.Time)
    createdate = db.Column(db.DateTime, default=db.func.now())

    def __repr__(self):
        return self.id

    def to_dict(self):
        return {
            'name': self.name,
            'text': self.text,
            'date': str(self.date),
            'status': self.status,
            'createdate': str(self.createdate)
        }
Beispiel #21
0
class Lesson(db.Model):
    __tablename__ = "lesson"
    id = db.Column(db.Integer,primary_key=True)
    course =
    name = db.Column(db.String(100))
    add_time = db.Column(db.DateTime,default=datetime.now)



    def __repr__(self):
        return '<Lesson {}>'.format(self.name)
Beispiel #22
0
class Tags(Model):
    __tablename__ = 'tags'

    id = db.Column(db.Integer, primary_key=True)
    tagname = db.Column(db.String(100))

    def __init__(self, tagname):
        db.Model.__init__(self, tagname=tagname)

    def __repr__(self):
        return self.tagname
Beispiel #23
0
class Role(Model, SurrogatePK):
    """Role model"""
    __tablename__ = 'roles'
    name = db.Column(db.String(80), unique=True, index=True)  # 角色名称
    description = db.Column(db.String(255))  # 角色描述

    def __repr__(self):
        # return '<Role %r>' % self.name
        return self.description

    @classmethod
    def init_role(cls):
        superadmin = cls.get_or_create(q={"name": "superadmin"},
                                       description="超级管理员")

        chief = cls.get_or_create(q={"name": "chief"}, description="主管")
        admin = cls.get_or_create(q={"name": "admin"}, description="管理员")
        default = cls.get_or_create(q={"name": "default"}, description="默认")

        return superadmin, chief, admin, default
Beispiel #24
0
class Log(db.Model):
    __tablename__ = 'log'

    id = db.Column(db.Integer, primary_key=True)
    amount = db.Column(db.Float(precision='8', decimal_return_scale='2'))
    currency = db.Column(ChoiceType(CURRENCY_CHOICE))
    description = db.Column(db.String(4096))
    created = db.Column(db.DateTime, default=datetime.datetime.now)

    def __str__(self):
        return self.id
Beispiel #25
0
class Teacher(db.Model):
    """
    讲师
    """
    __tablename__ = 'teacher'
    id = db.Column(db.Integer, primary_key=True)
    org_id = db.Column(db.Integer, db.ForeignKey('org.id'))
    name = db.Column(db.String(50))
    work_years = db.Column(db.Integer, default=0)
    work_company = db.Column(db.String(50))
    work_position = db.Column(db.String(50))
    age = db.Column(db.Integer, default=0)
    points = db.Column(db.String(50))  # 教学特点
    click_nums = db.Column(db.Integer, default=0)
    fav_nums = db.Column(db.Integer, default=0)
    courses = db.relationship('Course', backref='teacher', lazy='dynamic')
    add_time = db.Column(db.DateTime(), default=datetime.now)

    def __repr__(self):
        return '<Teacher {}>'.format(self.name)
Beispiel #26
0
class Paper(SurrogatePK, Model):
    __tablename__ = 'papers'

    id = Column(db.Integer, primary_key=True, autoincrement=True)
    filename = Column(db.String(100), unique=True, nullable=False)

    def __init__(self, filename):
        db.Model.__init__(self, filename=filename)

    def __repr__(self):
        return '<Paper({filename!r})'.format(filename=self.filename)
Beispiel #27
0
class Results(db.Model):
    __tablename__ = "Results"
    __table_args__ = {'extend_existing': True}

    personEmail = db.Column(db.String(80), nullable=False, primary_key=True)
    model = db.Column(db.String(80), nullable=False, primary_key=True)
    preprocessor = db.Column(db.String(80), nullable=False, primary_key=True)
    resource = db.Column(db.String(80), nullable=False, primary_key=True)
    datetime = db.Column(db.DateTime,
                         default=datetime.now,
                         server_default=text('now()'),
                         primary_key=True)
    accuracy = db.Column(db.Float)
    precision = db.Column(db.Float)
    recall = db.Column(db.Float)
    roc_auc = db.Column(db.Float)
    log_loss = db.Column(db.Float)

    def __repr__(self):
        return f'{type(self).__name__} <{self.personEmail}>: <{self.model}>-<{self.preprocessor}>-<{self.resource}>:' \
               f'{self.datetime}'
Beispiel #28
0
class AgeGroups(db.Model):
  __tablename__ = 'age_groups'

  id = db.Column(db.Integer,
                  primary_key=True)

  name = db.Column(db.String(80),
                    unique=False,
                    nullable=False)

  def __repr__(self):
    return f"ProgramAge('{self.name}')"
Beispiel #29
0
class Aliases(db.Model):
    __tablename__ = "aliases"
    id = db.Column(db.Integer, primary_key=True)
    office = db.Column(db.String(100))
    task = db.Column(db.String(100))
    ticket = db.Column(db.String(100))
    name = db.Column(db.String(100))
    number = db.Column(db.String(100))

    def __init__(self,
                 office="Office",
                 task="Task",
                 ticket="Ticket",
                 name="name",
                 number="number"):
        self.id = 0
        self.office = office
        self.task = task
        self.ticket = ticket
        self.name = name
        self.number = number
Beispiel #30
0
class Polluant(db.Model):
    __tablename__ = 'polluant'

    id = db.Column(db.Integer, primary_key=True)
    nom = db.Column(db.String(100), nullable=False)

    def __init__(self, id, nom):
        self.id = id
        self.nom = nom

    def __str__(self):
        return f'{self.nom}'