示例#1
0
    username = Column(String(200), unique=True)
    password = Column(String(100))

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

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

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


participant_hacknight = db.Table(
    'participant_hacknight',
    db.Column('participant_id', db.Integer, db.ForeignKey('participant.id')),
    db.Column('hacknight_id', db.Integer, db.ForeignKey('hacknight.id')))


class Participant(db.Model):
    """Participant model."""
    __tablename__ = 'participant'
    id = Column(Integer, autoincrement=True, primary_key=True)
    name = Column(String(50))
    lastname = Column(String(50))
    email = Column(String(200))
    github = Column(String(200), default="")
    phone = Column(String(13))


class Hacknight(db.Model):
示例#2
0
    password = Column(String(100))

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

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

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


participant_hacknight = db.Table(
    "participant_hacknight",
    db.Column("participant_id", db.Integer, db.ForeignKey("participant.id")),
    db.Column("hacknight_id", db.Integer, db.ForeignKey("hacknight.id")),
)


class Participant(db.Model):
    """Participant model."""

    __tablename__ = "participant"
    id = Column(Integer, autoincrement=True, primary_key=True)
    first_name = Column(String(50), nullable=False)
    last_name = Column(String(50), nullable=False)
    email = Column(String(200), unique=True, nullable=False)
    github = Column(String(200), unique=True, nullable=False)
    phone = Column(String(13))
    slack = Column(String(21))
示例#3
0
# coding=utf-8

from backend.extensions import db

association_draw_groups_players = db.Table(
    'association_draw_groups_players',
    db.Model.metadata,
    db.Column('player_id', db.Integer, db.ForeignKey('players.id')),
    db.Column('draw_group_id', db.Integer, db.ForeignKey('draw_groups.id')),
)


class DrawGroup(db.Model):
    __tablename__ = 'draw_groups'

    id = db.Column(db.Integer, primary_key=True)
    game_id = db.Column(db.Integer, db.ForeignKey('games.id'))
    game = db.relationship("Game", back_populates='draw_groups')
    players = db.relationship('Player',
                              secondary=association_draw_groups_players,
                              back_populates='draw_groups')

    def __init__(self, game):
        self.game = game
示例#4
0
from backend.extensions import db
from backend.utils import get_class_by_tablename

user_model = get_class_by_tablename("user")

type_association = db.Table(
    'type_association', db.metadata,
    db.Column("id", db.Integer, primary_key=True),
    db.Column('left_id', db.Integer, db.ForeignKey('post.id')),
    db.Column('right_id', db.Integer, db.ForeignKey('post_type.id')))

user_association = db.Table(
    'user_association', db.metadata,
    db.Column("id", db.Integer, primary_key=True),
    db.Column('left_id', db.Integer, db.ForeignKey('user.id')),
    db.Column('right_id', db.Integer, db.ForeignKey('post.id')))


class PostType(db.Model):
    __tablename__ = "post_type"

    id = db.Column(db.Integer, primary_key=True)
    type = db.Column(db.String, unique=True)
    active = db.Column(db.Boolean, default=True)

    def __str__(self):
        return str(self.type)


class Post(db.Model):
    __tablename__ = "post"
示例#5
0
from backend.extensions import db

association_table = db.Table(
    'watch_queue', db.Column('user_id', db.Integer, db.ForeignKey('user.id')),
    db.Column('series_id', db.Integer, db.ForeignKey('series.id')))


class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), unique=True, nullable=False)
    password = db.Column(db.String(60), nullable=False)
    watch_queue = db.relationship('Series',
                                  secondary=association_table,
                                  backref=db.backref('queue', lazy='dynamic'))


class Series(db.Model):
    __tablename__ = 'series'
    id = db.Column(db.Integer, primary_key=True)
    kitsu_id = db.Column(db.Integer, nullable=True)
    canonical_title = db.Column(db.String(120), nullable=True)
    en_title = db.Column(db.String(120), nullable=True)
    en_jp_title = db.Column(db.String(120), nullable=True)
    attributes = db.relationship('Attribute', uselist=False, backref='series')
    cover_image = db.relationship('CoverImage',
                                  uselist=False,
                                  backref='series')
    poster_image = db.relationship('PosterImage',
                                   uselist=False,
                                   backref='series')