Exemplo n.º 1
0
class Htmlbanner(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(100), nullable=False)
    width = db.Column(db.Integer, nullable=False)
    height = db.Column(db.Integer, nullable=False)
    content = db.Column(db.Text, nullable=False)
    click_link = db.Column(db.Text, nullable=False)
    audit_link = db.Column(db.Text, nullable=False)
    status = db.Column(db.Boolean(), nullable=False, default=False)
    trafkey = db.Column(db.String(20), nullable=False)
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    campaign_id = db.Column(db.Integer,
                            db.ForeignKey('campaign.id'),
                            nullable=False)
    ssps_htmlbanner = db.relationship('Ssp',
                                      secondary=ssps_htmlbanner,
                                      lazy='subquery',
                                      backref=db.backref('htmlbanners',
                                                         lazy=True))
    regions_htmlbanner = db.relationship('Region',
                                         secondary=regions_htmlbanner,
                                         lazy='subquery',
                                         backref=db.backref('htmlbanners',
                                                            lazy=True))
    operating_systems_htmlbanner = db.relationship(
        'Os',
        secondary=operating_systems_htmlbanner,
        lazy='subquery',
        backref=db.backref('htmlbanners', lazy=True))
Exemplo n.º 2
0
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(100), nullable=False)
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    content = db.Column(db.Text, nullable=False)
    image_file = db.Column(db.String(20), nullable=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)

    def __repr__(self):
        return f"Post('{self.title}', '{self.date_posted}')"
Exemplo n.º 3
0
class Campaign(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(100), nullable=False)
    campaign_hash = db.Column(db.String(20), nullable=False)
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    start_date = db.Column(db.Date, nullable=False)
    finish_date = db.Column(db.Date, nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    image_banner = db.relationship('Imagebanner',
                                   backref='parent_campaign',
                                   lazy=True)
    html_banner = db.relationship('Htmlbanner',
                                  backref='parent_campaign',
                                  lazy=True)
    status = db.Column(db.Boolean(), nullable=False, default=False)

    def __repr__(self):
        return f"Campaign('{self.title}', '{self.date_posted}', '{self.start_date}', '{self.finish_date}','{self.campaign_hash}')"
Exemplo n.º 4
0
                                   lazy=True)
    html_banner = db.relationship('Htmlbanner',
                                  backref='parent_campaign',
                                  lazy=True)
    status = db.Column(db.Boolean(), nullable=False, default=False)

    def __repr__(self):
        return f"Campaign('{self.title}', '{self.date_posted}', '{self.start_date}', '{self.finish_date}','{self.campaign_hash}')"


# соединительная таблица между Imagebanner и SSP
# используем для сопотавления названия SSP к конкретному баннеру-картинке
# потому что у каждого баннера может быть несколько сспшек в качестве источников трафика
ssps_imagebanner = db.Table(
    'ssps_imagebanner',
    db.Column('ssp_id', db.Integer, db.ForeignKey('ssp.id'), primary_key=True),
    db.Column('banner_id',
              db.Integer,
              db.ForeignKey('imagebanner.id'),
              primary_key=True))

regions_imagebanner = db.Table(
    'regions_imagebanner',
    db.Column('region_id',
              db.Integer,
              db.ForeignKey('region.id'),
              primary_key=True),
    db.Column('banner_id',
              db.Integer,
              db.ForeignKey('imagebanner.id'),
              primary_key=True))