예제 #1
0
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    author_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    created = db.Column(
        db.DateTime, default=datetime.utcnow, nullable=False)
    title = db.Column(db.String(140), nullable=False)
    body = db.Column(db.String(140), nullable=False)
예제 #2
0
class User(UserMixin, db.Model):
    __tablename__ = "portfolio_user"
    id = db.Column(db.Integer, primary_key=True)
    """User's id"""
    email = db.Column(db.String(128), index=True, unique=True, nullable=False)
    """User's email"""
    password_hash = db.Column(db.String(128), nullable=False)
    """User's hashed password"""
    accounts = db.relationship('InvestmentAccount')
    """Accounts owned by the user"""
    stock_transactions = db.relationship('StockTransaction')
    """StockTransactions beloning to the user"""
    def __iter__(self):
        yield ('email', self.email)

    def __repr__(self):
        return '<User {}>'.format(self.id)

    def set_password(self, password):
        """
        Hashes the password and saves it as the user's password_hash

        Keyword arguments:
        password -- the user's password
        """
        self.password_hash = generate_password_hash(password)

    def check_password(self, password):
        """
        Hashes the password and checks if it is equal to the user's password_hash

        Keyword arguments:
        password -- the user's password
        """
        return check_password_hash(self.password_hash, password)
예제 #3
0
class admin(db.Model):
    id = db.Column(db.INTEGER, primary_key=True, autoincrement=True)
    name = db.Column(db.String(30), nullable=False)
    pwd = db.Column(db.String(30), nullable=False)
    is_super = db.Column(db.SmallInteger, nullable=False)
    oplogs = db.relationship("oplog", back_populates="adminId")
    adminlogs = db.relationship("adminlog", back_populates="adminId")
예제 #4
0
class SmsTemplate(db.Model):
    __tablename__ = "smsTemplate"
    templateId = db.Column(db.Integer, primary_key=True)
    templateName = db.Column(db.String(200))
    templateContent = db.Column(db.String(500))
    smsType = db.Column(db.Integer)
    international = db.Column(db.Integer)
    remark = db.Column(db.String(500))
    statusCode = db.Column(db.Integer, default=1)
    reviewReply = db.Column(db.String(500))
    createTime = db.Column(db.DateTime, default=datetime.datetime.now)
    secretId = db.Column(db.String(100))

    def __init__(self, templateName, templateContent, smsType, international,
                 remark, secretId):
        self.templateName = templateName
        self.templateContent = templateContent
        self.smsType = smsType
        self.international = international
        self.remark = remark
        self.secretId = secretId

    def to_json(self):
        return {
            "TemplateId": self.templateId,
            "TemplateName": self.templateName,
            "International": self.international,
            "CreateTime": int(time.mktime(self.createTime.timetuple())),
            "ReviewReply": self.reviewReply,
            "StatusCode": self.statusCode
        }
class Product(db.Model):
    __tablename__ = 'product'
    __table_args__ = {'mysql_collate': 'utf8_general_ci'}

    product_name = db.Column(db.String(30),
                             primary_key=True,
                             unique=True,
                             nullable=False)
    product_price = db.Column(db.Integer, nullable=False)
    product_sales = db.Column(db.Integer, nullable=False)
    product_num = db.Column(db.Integer, nullable=False)

    def __init__(self, product_name, product_price, product_sales,
                 product_num):
        self.product_name = product_name
        self.product_price = product_price
        self.product_sales = product_sales
        self.product_num = product_num

    def __repr__(self):
        return 'product_name : %s, product_price : %s, product_sales : %s, product_num : %s' % (
            self.product_name, self.product_price, self.product_sales,
            self.product_num)

    def as_dict(self):
        return {x.name: getattr(self, x.name) for x in self.__table__.columns}
예제 #6
0
class Hashtag(db.Model):
    __tablename__ = 'Hashtag'
    id = db.Column(db.Integer, primary_key=True, nullable=False)
    value = db.Column(db.String, nullable=False)

    def serialize(self):
        return {'id': self.id, 'value': self.value}
예제 #7
0
class Image(db.Model):
    imageid = db.Column(db.Integer, primary_key=True)
    path = db.Column(db.String(140))
    userid = db.Column(db.Integer, db.ForeignKey('user.userid'))

    def __repr__(self):
        return '<Post {}>'.format(self.path)
예제 #8
0
class User(UserMixin, db.Model):

    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(64), unique=True, index=True)
    username = db.Column(db.String(64), index=True)
    password = db.Column(db.String(128))

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

    def validate_password(self, password):
        return check_password_hash(self.password, password)

    def add_user(self):
        with db.session.begin(subtransactions=True):
            db.session.add(self)
        db.session.commit()

    @classmethod
    def select_by_email(cls, email):
        return cls.query.filter_by(email=email).first()
예제 #9
0
파일: models.py 프로젝트: ebichiki/flaskr
class User(db.Model):
    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), default='', nullable=False)
    email = db.Column(db.String(100), unique=True, nullable=False)
    _password = db.Column('password', db.String(100), nullable=False)

    def _get_password(self):
        return self._password

    def _set_password(self, password):
        if password:
            password = password.strip()
        self._password = generate_password_hash(password)

    password_descriptor = property(_get_password, _set_password)
    password = synonym('_password', descriptor=password_descriptor)

    def check_password(self, password):
        password = password.strip()
        if not password:
            return False
        return check_password_hash(self.password, password)

    @classmethod
    def authenticate(cls, query, email, password):
        user = query(cls).filter(cls.email == email).first()
        if user is None:
            return None, False
        return user, user.check_password(password)

    def __repr__(self):
        return u'<User id={self.id} email={self.email!r}>'.format(self=self)
예제 #10
0
class Sex(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    type = db.Column(db.String(25), unique=True, nullable=False)
    user = db.relationship('Users', backref='sex', lazy=True)
    admin = db.relationship('Admin', backref='sex', lazy=True)

    def __repr__(self):
        return '<Sex %r>' % self.type
예제 #11
0
파일: models.py 프로젝트: yktsnd/test
class Entry(db.Model):
    __tablename__ = 'entries'
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.Text)
    text = db.Column(db.Text)

    def __repr__(self):
        return '<Entry id={id} title={title}>'.format(id=self.id, title=self.title)
예제 #12
0
class Adminlog(db.Model):
    id = db.Column(db.INTEGER, primary_key=True, autoincrement=True)
    Admin_id = db.Column(db.Integer, db.ForeignKey('admin.id'))
    ip = db.Column(db.String(100), nullable=False)
    addtime = db.Column(db.DateTime,
                        nullable=False,
                        index=True,
                        default=datetime.datetime.now())
예제 #13
0
class role(db.Model):
    id = db.Column(db.INTEGER, primary_key=True, autoincrement=True)
    adminName = db.Column(db.String(30), nullable=False)
    auths = db.Column(db.String(60), nullable=False)
    addTime = db.Column(db.Date,
                        index=True,
                        nullable=False,
                        default=datetime.datetime.now())
예제 #14
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    pwd = db.Column(db.String(50), nullable=False)
    username = db.Column(db.String(20), unique=True, nullable=False)
    posts = db.relationship('Post', backref='author', lazy=True)

    def __repr__(self):
        return f"User('{self.username}')"
예제 #15
0
class tag(db.Model):
    id = db.Column(db.INTEGER, primary_key=True, autoincrement=True)
    addtime = db.Column(db.DateTime,nullable=False,index=True,default=datetime.datetime.now())
    tagName = db.Column(db.String(200), nullable=False)

    movies = db.relationship("movie",
                             secondary=movie_tag,
                             back_populates="tag_id")
예제 #16
0
class FavoriteCreator(db.Model):
    __table_args__ = ({'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'})
    user_id = db.Column(db.Integer, primary_key=True, nullable=False)
    creator_id = db.Column(db.Integer, primary_key=True, nullable=False)
    checked = db.Column(TINYINT(1), nullable=False, default=0)
    mod_datetime = db.Column(db.DATETIME,
                             default=datetime.now,
                             onupdate=datetime.now)
예제 #17
0
class MemberTracking(db.Model):
    __table_args__ = ({'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'})
    tracking_id = db.Column(db.VARCHAR(200), primary_key=True, nullable=False)
    member_id = db.Column(db.VARCHAR(20), primary_key=True, nullable=False)
    is_delete = db.Column(TINYINT(1), nullable=False, default=0)
    mod_datetime = db.Column(db.DATETIME,
                             default=datetime.now,
                             onupdate=datetime.now)
예제 #18
0
class Chiryo(db.Model):
    __tablename__ = 'chiryos'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50))
    hospital_id = db.Column(db.Integer,
                            db.ForeignKey('hospitals.id'),
                            nullable=False)
예제 #19
0
파일: models.py 프로젝트: lordp/rova
class Artist(db.Model):
    __tablename__ = "artists"

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(250), nullable=False)
    slug = db.Column(db.String(250), nullable=False, index=True)
    songs = relationship("Song", back_populates="artist")
    plays = relationship("Played", back_populates="artist")
예제 #20
0
class MailMagazine(db.Model):
    __table_args__ = ({'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'})
    user_id = db.Column(db.Integer, primary_key=True, nullable=False)
    category = db.Column(db.VARCHAR(50), primary_key=True, nullable=False)
    checked = db.Column(TINYINT(1), nullable=False, default=0)
    mod_datetime = db.Column(db.DATETIME,
                             default=datetime.now,
                             onupdate=datetime.now)
예제 #21
0
파일: models.py 프로젝트: lordp/rova
class Played(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    song_id = db.Column(db.Integer, db.ForeignKey("songs.id"), index=True)
    song = relationship("Song")
    artist_id = db.Column(db.Integer, db.ForeignKey("artists.id"), index=True)
    artist = relationship("Artist")
    station = db.Column(db.String(250), nullable=False, index=True)
    played_time = db.Column(db.DateTime(timezone=True), index=True)
예제 #22
0
class User(db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer,primary_key=True)
    username = db.Column(db.String(100), default='', nullable=False)
    password = db.Column('password', db.String(100), nullable=False)

    def __repr__(self):
        return '<Entry id={id},username={username!r},password={password!r}>'.format(id=self.id, username=self.username, password=self.password)
예제 #23
0
class Note(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(20))
    body = db.Column(db.String(255))

    def __init__(self, title, body):
        self.title = title
        self.body = body
예제 #24
0
class Auth(db.Model):
    id = db.Column(db.INTEGER, primary_key=True, autoincrement=True)
    name = db.Column(db.String(200), nullable=False)
    url = db.Column(db.String(600), nullable=False)
    addtime = db.Column(db.DateTime,
                        nullable=False,
                        index=True,
                        default=datetime.datetime.now())
예제 #25
0
class Lesson(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    student = db.Column(db.Integer, db.ForeignKey('student.id'))
    topic = db.Column(db.String, nullable=True)
    date = db.Column(db.DateTime, default=datetime.utcnow())

    def __repr__(self):
        return f"{self.topic}, {self.date.date()}"
예제 #26
0
class UploadFiles(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    fileName = db.Column(db.String(100))
    createdon = db.Column(db.DateTime)

    def __init__(self, fileName, createdon):
        self.fileName = fileName
        self.createdon = createdon
예제 #27
0
class Payment(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    value = db.Column(db.Float)
    date = db.Column(db.DateTime, default=datetime.utcnow())
    student = db.Column(db.Integer, db.ForeignKey('student.id'))

    def __repr__(self):
        return f"{self.value}zł from {Student.query.filter_by(id=self.student).first()}"
예제 #28
0
class secert(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    secert = db.Column(db.String(80), unique=True)

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

    def __repr__(self):
        return '<secert %r>' % self.secert
예제 #29
0
class AuditLog(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    action = db.Column(db.String(80), nullable=False)
    date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)

    def __init__(self, user_id, action):
        self.user_id = user_id
        self.action = action
예제 #30
0
class User(db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(128), unique=True)
    password = db.Column(db.String(255))

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