예제 #1
0
파일: Comment.py 프로젝트: gladioluz/Floggy
class Comment(db.Model):
    __tablename__ = 'comments'

    id = db.Column(UUID(), primary_key=True)
    user_id = db.Column(UUID(), db.ForeignKey('users.id'), index=True)
    content_id = db.Column(UUID(), db.ForeignKey('contents.id'), index=True)
    body = db.Column(db.Text())

    created = db.Column(db.DateTime)
예제 #2
0
class User(db.Model):
    __tablename__ = 'users'

    id = db.Column(UUID(), primary_key=True)
    avatar = db.Column(db.String(256))
    username = db.Column(db.String(64), unique=True, index=True)
    email = db.Column(db.String(64), unique=True, index=True)
    password_hash = db.Column(db.String(128))
    role = db.Column(db.String(16))

    registered = db.Column(db.DateTime)
    active = db.Column(db.Boolean)

    is_anonymous = False

    def __init__(self, avatar, username, email, role):
        self.id = uuid.uuid4().urn
        self.avatar = avatar
        self.username = username
        self.email = email
        self.role = role
        self.datetime = datetime.datetime.utcnow()
        self.active = True

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

    def is_authenticated(self):
        return True

    def is_active(self):
        return self.active

    def get_id(self):
        return self.id

    def get_urole(self):
        return self.role

    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)
예제 #3
0
class ContentType(db.Model):
    __tablename__ = 'content_types'

    id = db.Column(UUID(), primary_key=True)
    name = db.Column(db.String(64))
    uri = db.Column(db.String(64))
예제 #4
0
파일: Setting.py 프로젝트: gladioluz/Floggy
class Setting(db.Model):
    __tablename__ = 'settings'

    id = db.Column(db.Integer, primary_key=True)
    key = db.Column(db.String(32))
    value = db.Column(db.String(256))
예제 #5
0
파일: Tag.py 프로젝트: gladioluz/Floggy
class Tag(db.Model):
    __tablename__ = 'tags'

    id = db.Column(UUID(), primary_key=True)
    name = db.Column(db.String(64))
예제 #6
0
class ContentRelated(db.Model):
    __tablename__ = 'content_related'

    id = db.Column(UUID(), primary_key=True)
    content_id = db.Column(UUID(), db.ForeignKey('contents.id'), index=True)
    to_content_id = db.Column(UUID(), db.ForeignKey('contents.id'))
예제 #7
0
파일: Content.py 프로젝트: gladioluz/Floggy
class Content(db.Model):
    __tablename__ = 'contents'

    id = db.Column(UUID(), primary_key=True)
    uri = db.Column(db.String(64), unique=True, index=True)
    content_type_id = db.Column(UUID(),
                                db.ForeignKey('content_types.id'),
                                index=True)
    rubric_id = db.Column(UUID(), db.ForeignKey('rubrics.id'), index=True)
    user_id = db.Column(UUID(), db.ForeignKey('users.id'), index=True)
    title_seo = db.Column(db.String(64))
    description_seo = db.Column(db.String(160))
    preview = db.Column(db.String(128))
    alt = db.Column(db.String(64))
    content_image = db.Column(db.String(128))
    language_seo = db.Column(db.String(2))
    title = db.Column(db.String(128))
    description = db.Column(db.Text())
    body = db.Column(db.Text())

    rating = db.Column(db.Integer(), default=0)
    seen = db.Column(db.Integer(), default=0)
    comment_count = db.Column(db.Integer(), default=0)

    created = db.Column(db.DateTime())
    updated = db.Column(db.DateTime())

    status = db.Column(db.SmallInteger())
예제 #8
0
파일: Rubric.py 프로젝트: gladioluz/Floggy
class Rubric(db.Model):
    __tablename__ = 'rubrics'

    id = db.Column(UUID(), primary_key=True)
    name = db.Column(db.String(64))
    uri = db.Column(db.String(64))