Beispiel #1
0
class Project(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(250), unique=True)
    button = db.Column(db.String(36), unique=True)
    background_images = db.relationship('BackgroundImage',
                                        backref='project',
                                        lazy='dynamic')
    fonts = db.relationship('Font', backref='project')
    headers = db.relationship('Header', backref='project')
    banners = db.relationship('Banner', backref='project')
Beispiel #2
0
class Role(db.Model):
    __tablename__ = 'roles'

    role_id = db.Column(db.Integer, primary_key=True)
    role_name = db.Column(db.String(128), unique=True, nullable=False)
    permissions = db.Column(db.ARRAY(db.String(128)), nullable=False)

    def __init__(self, role_name, permissions):
        self.role_name = role_name
        self.permissions = permissions
Beispiel #3
0
class BaseImage(db.Model):
    __abstract__ = True
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), unique=True)
    title = db.Column(db.String(120), unique=False)
    preview = db.Column(db.String(64), unique=True)
    active = db.Column(db.BOOLEAN, default=True, nullable=False)

    def __repr__(self):
        return '<Image %r>' % self.name
Beispiel #4
0
class Trail(db.Model):
    __tablename__ = 'trails'

    id = db.Column(db.Integer, primary_key=True)
    created = db.Column(db.DateTime, default=datetime.utcnow)
    title = db.Column(db.String(256))
    description = db.Column(db.String(1024))
    path = db.Column(JSON)
    trail_head_address = db.Column(db.String(256))
    length = db.Column(db.Float(precision=6, asdecimal=False))
Beispiel #5
0
class User(db.Model):
    class Gender(enum.Enum):
        male = 0
        female = 1

    class UserRole(enum.Enum):
        user = 0
        designer = 1
        admin = 2

    class SocialNetwork(enum.Enum):
        google = 0
        facebook = 1

    __tablename__ = 'user'
    id = db.Column(db.Integer, primary_key=True)
    social_id = db.Column(db.String(255))
    social_type = db.Column(Enum(SocialNetwork), nullable=False)
    first_name = db.Column(db.String(255))
    last_name = db.Column(db.String(255))
    gender = db.Column(Enum(Gender))
    email = db.Column(db.String(255), unique=True)
    role = db.Column(Enum(UserRole), nullable=False)
    created_at = db.Column(db.DateTime,
                           nullable=False,
                           default=datetime.datetime.utcnow)
    active = db.Column(db.BOOLEAN, default=True, nullable=False)
    banners = db.relationship('Banner', backref='user')

    __table_args__ = (Index('ix_user_id_social_type', "social_type", "id"), )

    def is_authenticated(self):
        return True

    def is_active(self):
        return self.active

    def is_anonymous(self):
        return False

    def is_user(self):
        return self.role == User.UserRole.user

    def is_designer(self):
        return self.role == User.UserRole.designer

    def is_admin(self):
        return self.role == User.UserRole.admin

    def get_id(self):
        return unicode(self.id)

    def __repr__(self):
        return '<User %r>' % self.first_name
Beispiel #6
0
class Setting(db.Model):
    __tablename__ = 'settings'

    setting_id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(128), unique=True, nullable=False)
    password = db.Column(db.String(128), unique=True, nullable=False)
    active = db.Column(db.Boolean(), default=False, nullable=False)

    def __init__(self, username, password):
        self.username = username
        self.password = password
Beispiel #7
0
class Font(db.Model):
    __tablename__ = 'font'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255))
    filename = db.Column(db.String(255))
    project_id = db.Column(db.Integer, db.ForeignKey('project.id'))
    headers = db.relationship('Header', backref='font', cascade="delete")

    __table_args__ = (UniqueConstraint('project_id',
                                       'name',
                                       name='project_font'), )

    def url(self):
        return url_for('uploaded_file', filename=self.filename)
Beispiel #8
0
class Header(db.Model):
    __tablename__ = 'header'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255))
    project_id = db.Column(db.Integer, db.ForeignKey('project.id'), index=True)
    font_id = db.Column(db.Integer, db.ForeignKey('font.id'))
    size = db.Column(db.Integer())
Beispiel #9
0
class Gallery_Info(db.Model):
    __tablename__ = 'gallery_info'

    gallery_id = db.Column(db.Integer, primary_key=True)
    gallery_name = db.Column(db.String(128), unique=True, nullable=False)
    description = db.Column(db.Text(), nullable=True)
    last_updated = db.Column(db.DateTime(False), nullable=True)
    last_updated_by = db.Column(db.String(128), nullable=True)

    # galleries_rel = db.relationship('Galleries', backref=db.backref(
    #     "Galleries"), ondelete="cascade")

    def __init__(self, gallery_name, description, last_updated,
                 last_updated_by):
        self.gallery_name = gallery_name
        self.description = description
        self.last_updated = last_updated
        self.last_updated_by = last_updated_by
Beispiel #10
0
class Image(db.Model):
    __tablename__ = 'images'

    image_id = db.Column(db.Integer, primary_key=True)
    image_link = db.Column(db.Text, nullable=False)
    image_name = db.Column(db.String(50), nullable=False)

    def __init__(self, image_link, image_name):
        self.image_link = image_link
        self.image_name = image_name
Beispiel #11
0
class Blacklist(db.Model):
    __tablename__ = 'blacklist'

    id = db.Column(db.Integer, primary_key=True)
    quickbooks_id = db.Column(db.Integer, nullable=False)
    name = db.Column(db.String(128), nullable=False)
    email = db.Column(db.String(128), nullable=False)
    phone = db.Column(db.String(128), nullable=False)
    start_date = db.Column(db.DateTime(), nullable=False)
    end_date = db.Column(db.DateTime(), nullable=True)
    reason = db.Column(db.String(128), nullable=False)

    def __init__(self, quickbooks_id, name, email, phone, start_date, end_date, reason):
        self.quickbooks_id = quickbooks_id
        self.name = name
        self.email = email
        self.phone = phone
        self.start_date = start_date
        self.end_date = end_date
        self.reason = reason
Beispiel #12
0
class BannerReview(db.Model):
    class Status(enum.Enum):
        accepted = 0
        not_accepted = 1

    id = db.Column(db.Integer, primary_key=True)
    banner_id = db.Column(db.Integer, db.ForeignKey('banner.id'))
    comment = db.Column(db.Text, nullable=True)
    reviewed = db.Column(db.Boolean, default=False)
    status = db.Column(Enum(Status))
    created_at = db.Column(db.DateTime, default=datetime.datetime.utcnow)
    designer_comment = db.Column(db.Text, nullable=True)
    changed_at = db.Column(db.DateTime, nullable=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    designer_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    designer_imagename = db.Column(db.String(64), unique=True)
    designer_previewname = db.Column(db.String(64), unique=True)
    active = db.Column(db.BOOLEAN, default=True, nullable=False)
    comment_clouds = db.Column(JSON, nullable=True)

    user = db.relationship("User", foreign_keys=[user_id])
    designer = db.relationship("User", foreign_keys=[designer_id])
Beispiel #13
0
class UserModel(db.Model):
    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80))
    password = db.Column(db.String(80))

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

    def save_to_db(self):
        db.session.add(self)
        db.session.commit()

    @classmethod
    def find_by_username(cls, username):
        return cls.query.filter_by(username=username).first()

    @classmethod
    def find_by_id(cls, _id):
        return cls.query.filter_by(id=_id).first()
Beispiel #14
0
class Admin(db.Model):
    __tablename__ = 'admins'

    user_id = db.Column(db.Integer, primary_key=True)
    first_name = db.Column(db.String(128), unique=False, nullable=False)
    last_name = db.Column(db.String(128), unique=False, nullable=False)
    email = db.Column(db.String(128), unique=True, nullable=False)
    username = db.Column(db.String(128), unique=True, nullable=False)
    password = db.Column(db.Text, nullable=False)
    role = db.Column(db.String(128), unique=False, nullable=False)
    recovery_link = db.Column(db.Text, unique=False, nullable=True)
    active = db.Column(db.Boolean(), default=False, nullable=False)
    last_logged_in = db.Column(db.DateTime(False), nullable=True)

    def __init__(self, first_name, last_name, email, username, password, role,
                 recovery_link, last_logged_in):
        self.first_name = first_name
        self.last_name = last_name
        self.email = email
        self.username = username
        self.password = password
        self.recovery_link = recovery_link
        self.role = role
        self.last_logged_in = last_logged_in