class PodCastFileAdditionalData(db.Model): id = db.Column(db.Integer(), primary_key=True) podcastHost = db.Column(db.String(length=100), nullable=False) podcastParticipants = db.relationship('PodCastParticipants', backref='participant_id', lazy=True) fileId = db.Column(db.Integer(), db.ForeignKey('audio_files.id'))
class User(db.Model, UserMixin): # Create a table in the db __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) profile_image = db.Column(db.String(20), nullable=False, default='default_profile.png') email = db.Column(db.String(64), unique=True, index=True) name = db.Column(db.String(64)) username = db.Column(db.String(64), unique=True, index=True) bio = db.Column(db.String(500)) password_hash = db.Column(db.String(128)) posts = db.relationship('Post', backref='user', lazy=True, order_by="desc(Post.date)") def __init__(self, email, username, name, password): self.email = email self.username = username self.name = name self.password_hash = generate_password_hash(password) def check_password(self, password): return check_password_hash(self.password_hash, password) def __repr__(self): return f"UserName: {self.username}"
class Post(db.Model): # Setup the relationship to the User table #user = db.relationship(User) # I will check if things work without things # Model for the Blog Posts on Website id = db.Column(db.Integer, primary_key=True) # Notice how we connect the BlogPost to a particular author user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False) date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) text = db.Column(db.Text, nullable=False) image = db.Column(db.String(20), default=None) def __init__(self, text, user_id): self.text = text self.user_id = user_id def __repr__(self): return f"Post Id: {self.id} --- Date: {self.date} "
class AudioFiles(db.Model): id = db.Column(db.Integer(), primary_key=True) fileName = db.Column(db.String(length=100), nullable=False) duration = db.Column(BIGINT(unsigned=True), nullable=False) uploadedTime = db.Column(db.DateTime, nullable=False) filePath = db.Column(db.String(length=150), nullable=True) audioFileType = db.Column(db.Integer(), db.ForeignKey('config_file_type.id')) songFile = db.relationship('SongFileAdditionalData', backref='song_file_id', lazy=True) audioBookFile = db.relationship('AudioBookAdditionalData', backref='audio_book_file_id', lazy=True) podcastFile = db.relationship('PodCastFileAdditionalData', backref='podcast_file_id', lazy=True) isActive = db.Column(db.Boolean(), nullable=False, default=1)
class ConfigFileType(db.Model): id = db.Column(db.Integer(), primary_key=True) fileTypeCode = db.Column(db.Integer(), nullable=False) fileType = db.Column(db.String(length=50), nullable=False)
class PodCastParticipants(db.Model): id = db.Column(db.Integer(), primary_key=True) podcastId = db.Column(db.Integer(), db.ForeignKey('pod_cast_file_additional_data.id')) podcastParticipantName = db.Column(db.String(length=100), nullable=False)
class AudioBookAdditionalData(db.Model): id = db.Column(db.Integer(), primary_key=True) audioBookTitleAuthor = db.Column(db.String(length=100), nullable=False) audioBookNarrator = db.Column(db.String(length=100), nullable=False) fileId = db.Column(db.Integer(), db.ForeignKey('audio_files.id'))
class SongFileAdditionalData(db.Model): id = db.Column(db.Integer(), primary_key=True) fileId = db.Column(db.Integer(), db.ForeignKey('audio_files.id'))