class ClubTable(db.Model): __tablename__ = 'clubtable' #The User would just be the Prof. in charge of the Club# user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) CID = db.Column(db.String(8), primary_key=True, unique=True, nullable=False)
class AdminTable(db.Model): __tablename__ = 'admintable' user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) EID = db.Column(db.String(8), primary_key=True, unique=True, nullable=False) position = db.Column(db.String(50), nullable=True) admin_level = db.Column(db.Enum(ADMIN_LEVEL), nullable=True)
class StudentTable(db.Model): __tablename__ = 'studenttable' #__table_args__ = ( PrimaryKeyConstraint('user_id', 'SID'),) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) SID = db.Column(db.String(8), primary_key=True, unique=True, nullable=False) branch = db.Column(db.Enum(BRANCH), nullable=False) program = db.Column(db.Enum(PROGRAM), nullable=False) year = db.Column(db.Enum(YEAR), default=YEAR.first, nullable=False)
class FacultyTable(db.Model): __tablename__ = 'facultytable' user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) # enrol = db.relationship('Enrol', backref='enrolling_faculty', lazy=True) FID = db.Column(db.String(8), primary_key=True, unique=True, nullable=False) branch = db.Column(db.Enum(BRANCH), nullable=False) position = db.Column(db.String(50), nullable=True)
class Course(db.Model): __tablename__ = 'course' # enrol_info = db.relationship('Enrol', backref='enroled_course', lazy=True) id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(50), unique=True, nullable=True) code = db.Column(db.String(6), primary_key=True, unique=True, nullable=False) credits = db.Column(db.Integer, unique=False, nullable=True) LTP = db.Column(db.String(3), unique=False, nullable=True) objectives = db.Column(db.String(500), unique=False, nullable=True) profsIDs = db.Column(db.String(27), unique=False, nullable=False) tot_classes = db.Column(db.Integer, unique=False, nullable=False)
class Enrol(db.Model): __tablename__ = 'enrol' fac_id = db.Column(db.Integer, db.ForeignKey('facultytable.FID'), nullable=False) course_id = db.Column(db.Integer, db.ForeignKey('course.id'), nullable=False) id = db.Column(db.Integer, primary_key=True) branch = db.Column(db.Enum(BRANCH), nullable=False) program = db.Column(db.Enum(PROGRAM), nullable=False) year = db.Column(db.Enum(YEAR), default=YEAR.first, nullable=False)
class User(db.Model, UserMixin): __tablename__ = 'user' 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) first_name = db.Column(db.String(25), unique=False, nullable=False) middle_name = db.Column(db.String(25), unique=False, nullable=True) last_name = db.Column(db.String(25), unique=False, nullable=True) DOB = db.Column(db.DateTime, unique=False, nullable=True) gender = db.Column(db.Enum(GENDER), default=GENDER.retard, nullable=False) user_group = db.Column(db.Enum(GROUP), default=GROUP.student, nullable=False) student_table = db.relationship('StudentTable', backref='userInfo', lazy=True) faculty_table = db.relationship('FacultyTable', backref='userInfo', lazy=True) admin_table = db.relationship('AdminTable', backref='userInfo', lazy=True) club_table = db.relationship('ClubTable', backref='userInfo', lazy=True)
class TimeTable(db.Model): __tablename__ = 'timetable' id = db.Column(db.Integer, primary_key=True) branch = db.Column(db.Enum(BRANCH), nullable=False) program = db.Column(db.Enum(PROGRAM), nullable=False) year = db.Column(db.Enum(YEAR), default=YEAR.first, nullable=False) day = db.Column(db.Enum(DAY), nullable=False) slot1 = db.Column(db.String(30), default=None, nullable=True) slot2 = db.Column(db.String(30), default=None, nullable=True) slot3 = db.Column(db.String(30), default=None, nullable=True) slot4 = db.Column(db.String(30), default=None, nullable=True) slot5 = db.Column(db.String(30), default=None, nullable=True) slot6 = db.Column(db.String(30), default=None, nullable=True) slot7 = db.Column(db.String(30), default=None, nullable=True) slot8 = db.Column(db.String(30), default=None, nullable=True) slot9 = db.Column(db.String(30), default=None, nullable=True) slot10 = db.Column(db.String(30), default=None, nullable=True)
class Assessments(db.Model): __tablename__ = 'assessments' id = db.Column(db.Integer, primary_key=True) sub_code = db.Column(db.String(6), unique=False, nullable=False)