class UserBlasts(db.Model): """ User has many blasts (join table)""" id = db.Column(db.Integer(), primary_key=True) user_id = db.Column(db.Integer(), db.ForeignKey('user.id', ondelete='CASCADE')) blast_id = db.Column(db.Integer(), db.ForeignKey('blast.id', ondelete='CASCADE'))
class UserConversations(db.Model): """ User has many conversations (join table)""" id = db.Column(db.Integer(), primary_key=True) user_id = db.Column(db.Integer(), db.ForeignKey('user.id', ondelete='CASCADE')) conversation_id = db.Column( db.Integer(), db.ForeignKey('conversation.id', ondelete='CASCADE')) pass
class UserRoles(db.Model): id = db.Column(db.Integer(), primary_key=True) user_id = db.Column(db.Integer(), db.ForeignKey('user.id', ondelete='CASCADE')) role_id = db.Column(db.Integer(), db.ForeignKey('role.id', ondelete='CASCADE')) # Relationships user = db.relationship('User', backref='roles') role = db.relationship('Role', backref='users')
class Message(db.Model): """ Message belongs to a conversation has many users """ id = db.Column(db.Integer, primary_key=True) created = db.Column(db.DateTime) content = db.Column(db.String) user_id = db.Column(db.Integer(), db.ForeignKey('user.id', ondelete='CASCADE')) conversation_id = db.Column( db.Integer(), db.ForeignKey('conversation.id', ondelete='CASCADE'))
class Like(db.Model): __tablename__ = "like" id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) image_id = db.Column(db.Integer, db.ForeignKey('image.id')) negate = db.Column(db.Integer) @classmethod def get_user_likes(self, user_id): return db.session.query(Like).filter(Like.user_id == user_id)
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) user_profile_id = db.Column(db.Integer(), db.ForeignKey('user_profile.id', ondelete='CASCADE')) # Flask-User fields active = db.Column(db.Boolean(), nullable=False, server_default='0') username = db.Column(db.String(50), nullable=False, unique=True) email = db.Column(db.String(255), nullable=False, unique=True) confirmed_at = db.Column(db.DateTime()) password = db.Column(db.String(255), nullable=False, server_default='') reset_password_token = db.Column(db.String(100), nullable=False, server_default='') # Relationships user_profile = db.relationship('UserProfile', uselist=False, backref="user")
class UserAuth(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer(), db.ForeignKey('user.id', ondelete='CASCADE')) # User authentication information (required for Flask-User) username = db.Column(db.String(50), nullable=False, unique=True) password = db.Column(db.String(255), nullable=False, server_default='') reset_password_token = db.Column(db.String(100), nullable=False, server_default='') active = db.Column(db.Boolean(), nullable=False, server_default='0') # Relationships user = db.relationship('User', uselist=False)
class UserRoles(db.Model): id = db.Column(db.Integer(), primary_key=True) user_id = db.Column(db.Integer(), db.ForeignKey('user.id', ondelete='CASCADE')) role_id = db.Column(db.Integer(), db.ForeignKey('role.id', ondelete='CASCADE'))
class Blast(db.Model): """ Blast """ id = db.Column(db.Integer, primary_key=True) creation = db.Column(db.DateTime) status = db.Column(db.String(), nullable=False, default="Pending") creater = db.Column(db.Integer, db.ForeignKey('user.id'))
class ThunderStorm(db.Model): """ User has many thunderstorms """ id = db.Column(db.Integer, primary_key=True) creation = db.Column(db.DateTime) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) status = db.Column(db.String(), nullable=False, default="Pending")