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))
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}')"
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) image_file = db.Column(db.String(20), nullable=False, default='default.jpg') password = db.Column(db.String(60), nullable=False) posts = db.relationship('Post', backref='author', lazy=True) campaigns = db.relationship('Campaign', backref='author', lazy=True) def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
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}')"
class Os(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100), nullable=False)
class Ssp(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100), nullable=False) type = db.Column(db.String(20), nullable=False) endpoint_url = db.Column(db.String(100), nullable=False)