Esempio n. 1
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())
Esempio n. 2
0
class Galleries(db.Model):
    __tablename__ = 'galleries'

    index_id = db.Column(db.Integer, primary_key=True)
    info_id = db.Column(db.Integer,
                        db.ForeignKey('gallery_info.gallery_id',
                                      ondelete="CASCADE"),
                        nullable=False)
    image_id = db.Column(db.Integer,
                         db.ForeignKey('images.image_id', ondelete="CASCADE"),
                         nullable=True)
    gallery_image = db.relationship('Image',
                                    backref=db.backref('galleries',
                                                       passive_deletes=True),
                                    foreign_keys=[image_id],
                                    lazy=True,
                                    uselist=False)
    gallery_info = db.relationship('Gallery_Info',
                                   passive_deletes=True,
                                   lazy=True,
                                   uselist=False)

    # cascade="all, delete" on gallery_info conflicts with update func

    def __init__(self):
        pass
Esempio n. 3
0
class Client_Resources(db.Model):
    __tablename__ = 'client_resources'

    resource_id = db.Column(db.Integer, primary_key=True)
    content_id = db.Column(db.Integer,
                           db.ForeignKey('headers.header_id'),
                           nullable=True)
    gallery_id = db.Column(db.Integer,
                           db.ForeignKey('gallery_info.gallery_id'),
                           nullable=True)
    linked_content = db.relationship('Header',
                                     passive_deletes=True,
                                     foreign_keys=[content_id],
                                     lazy=True,
                                     uselist=False)
    linked_gallery = db.relationship('Gallery_Info',
                                     passive_deletes=True,
                                     foreign_keys=[gallery_id],
                                     lazy=True,
                                     uselist=False)

    # cascade="all, delete" on gallery_info conflicts with update func

    def __init__(self):
        pass
Esempio n. 4
0
class Header(db.Model):
    __tablename__ = 'headers'

    header_id = db.Column(db.Integer, primary_key=True)
    header_text = db.Column(db.Text, nullable=False)
    image_id = db.Column(db.Integer,
                         db.ForeignKey('images.image_id', ondelete="SET NULL"),
                         nullable=True)
    paragraph_id = db.Column(db.Integer,
                             db.ForeignKey('paragraphs.paragraph_id'),
                             nullable=False)
    h_image = db.relationship('Image',
                              backref=db.backref('headers',
                                                 passive_deletes=True),
                              foreign_keys=[image_id],
                              lazy=True,
                              uselist=False)
    h_paragraph = db.relationship('Paragraph',
                                  backref='header',
                                  foreign_keys=[paragraph_id],
                                  lazy=True,
                                  cascade="all, delete",
                                  uselist=False)

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

    def __repr__(self):
        return f'<Header {self.header_id}, {self.header_text}><Paragraph {self.h_paragraph.paragraph_id}, {self.h_paragraph.paragraph_text}><Image {self.h_image.image_id}, {self.h_image.image_name}, {self.h_image.image_link}>'
Esempio n. 5
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])
Esempio n. 6
0
class ImageHistory(db.Model):
    __tablename__ = 'image_history'
    id = db.Column(db.Integer, primary_key=True)
    review_image = db.Column(db.Integer,
                             db.ForeignKey('banner.id'),
                             nullable=False)
    json_hist = db.Column(JSON, nullable=False)
    created = db.Column(db.DateTime,
                        default=datetime.datetime.utcnow,
                        nullable=False)

    def __str__(self):
        return 'History for image {0} created at {1}'.format(
            self.review_image, self.created)
Esempio n. 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)
Esempio n. 8
0
class BackgroundImage(BaseImage):
    project_id = db.Column(db.Integer, db.ForeignKey('project.id'))
    height = db.Column(db.Integer)
    width = db.Column(db.Integer)
Esempio n. 9
0
class Image(BaseImage):
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=True)
    description = db.Column(db.Text, nullable=True)
Esempio n. 10
0
class Banner(BaseImage):
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    project_id = db.Column(db.Integer, db.ForeignKey('project.id'))
    review = db.relationship('BannerReview', backref='banner', uselist=False)
    history = db.relationship('ImageHistory', backref="parent")