Esempio n. 1
0
class Users(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    email = db.Column(db.String(250), unique=True, nullable=False)
    name = db.Column(db.String(250), nullable=False)
    password = db.Column(db.String(), nullable=False)
    is_enabled = db.Column(db.Boolean(),
                           nullable=False,
                           server_default='False')

    def __init__(self, email, name, password, is_enabled=False):
        self.email = email
        self.name = name
        self.password = generate_password_hash(password)
        self.is_enabled = is_enabled

    def add(self, user):
        db.session.add(user)
        return session_commit()

    def update(self):
        return session_commit()

    def delete(self, user):
        db.session.delete(user)
        return session_commit()

    def is_active(self):
        return self.is_enabled
Esempio n. 2
0
class SeasonSchema(Schema):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    not_blank = validate.Length(min=1, error='Field cannot be blank')
    number = fields.Integer(validate=not_blank)
    overview = db.Column(db.TEXT())
    # Need to make this field
    #not blank on add
    art = fields.String()

    class Meta:
        fields = ('id', 'number', 'overview', 'art')
Esempio n. 3
0
class Season(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    number = db.Column(db.Integer)
    overview = db.Column(db.TEXT())
    art = db.Column(db.String())
    series = db.Column(db.Integer, db.ForeignKey(Series.id))

    def __init__(self, number, overview, art, series):
        self.number = number
        self.overview = overview
        self.art = art
        self.series = series
Esempio n. 4
0
class MovieSchema(Schema):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    not_blank = validate.Length(min=1, error='Field cannot be blank')
    title = fields.String(validate=not_blank)
    path = fields.String(validate=not_blank)
    overview = db.Column(db.TEXT())
    episode_number = fields.Integer()
    # Need to make this field
    #not blank on add
    image_path = fields.String()

    class Meta:
        fields = ('id', 'title', 'path', 'overview', 'episode_number',
                  'image_path')
Esempio n. 5
0
class Episode(Media_File):
    __table_args__ = {'extend_existing': True}
    __mapper_args__ = {'polymorphic_identity': 'Episode'}
    season = db.Column(db.Integer, db.ForeignKey(Season.id))
    episode_number = db.Column(db.Integer)

    def __init__(self, title, path, image_path, overview, season,
                 episode_number, tmdb_id):
        self.title = title
        self.slug = self.create_slug(title)
        self.path = path
        self.image_path = image_path
        self.overview = overview
        self.season = season
        self.episode_number = episode_number
        self.tmdb_id = tmdb_id

    def create_slug(self, title):
        return slugify(title)
Esempio n. 6
0
class Movie(Media_File):
    __table_args__ = {'extend_existing': True}
    __mapper_args__ = {'polymorphic_identity': 'Movie'}
    release_date = db.Column(db.Date)
    runtime = db.Column(db.Integer)

    def __init__(self, title, path, image_path, overview, release_date,
                 runtime, tmdb_id):
        self.title = title
        self.path = path
        self.slug = self.create_slug(title)
        self.image_path = image_path
        self.overview = overview
        self.release_date = release_date
        self.runtime = runtime
        self.tmdb_id = tmdb_id

    def create_slug(self, title):
        return slugify(title)
Esempio n. 7
0
class Media_File(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    title = db.Column(db.String(250))
    slug = db.Column(db.String(250))
    path = db.Column(db.String(250))
    image_path = db.Column(db.String(250))
    overview = db.Column(db.TEXT())
    media_type = db.Column(db.String(250))

    __mapper_args__ = {'polymorphic_on': media_type}
Esempio n. 8
0
class Series(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    tmdb_id = db.Column(db.Integer)
    title = db.Column(db.String(250))
    overview = db.Column(db.String(250), nullable=True)
    series_art = db.Column(db.String(250), nullable=True)
    slug = db.Column(db.String(250))

    def __init__(self, tmdb_id, title, overview, series_art):
        self.tmdb_id = tmdb_id
        self.title = title
        self.overview = overview
        self.series_art = series_art
        self.slug = self.create_slug(self.title)

    def create_slug(self, title):
        return slugify(title)
Esempio n. 9
0
class Tags(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    tag = db.Column(db.String(250))