class ScheduledCourse(db.Model): """ Class pertaining to a scheduled course for a course for a specific semester This contains data for the times, location, and enrollment of the class """ id = db.Column(db.Integer, primary_key=True) # data fields unique_no = db.Column(db.Integer, nullable=False) session = db.Column(db.String(1), nullable=True) days = db.Column(db.String(10)) time_from = db.Column(db.String(8)) time_to = db.Column(db.String(8)) location = db.Column(db.String(20)) max_enrollement = db.Column(db.Integer) seats_taken = db.Column(db.Integer) # deletion field mark_deletion = db.Column(db.Boolean, nullable=True, default=None) # id fields sem_id = db.Column(db.Integer, db.ForeignKey("semester.id"), nullable=False) course_id = db.Column(db.Integer, db.ForeignKey('course.id'), nullable=False) prof_id = db.Column(db.Integer, db.ForeignKey('prof.id'), nullable=True) cross_listed = db.Column(db.Integer, db.ForeignKey('cross_listed.id'), nullable=True) def __repr__(self): return f"""ScheduledCourse(
class Prof(db.Model): """ Class pertaining to a specific professor that taught at UT Austin """ id = db.Column(db.Integer, primary_key=True) # professor data fields first_name = db.Column(db.String(50), nullable=False) last_name = db.Column(db.String(50), nullable=False) eid = db.Column(db.String(10), unique=True, nullable=True) # ecis data fields (update on new ecis scores) ecis_avg = db.Column(db.Float, nullable=True) ecis_students = db.Column(db.Integer, nullable=False, default=0) # review data fields (update on new review submission) num_ratings = db.Column(db.Integer, default=0) approval = db.Column(db.Float, nullable=True) clear = db.Column(db.Float, nullable=True) engaging = db.Column(db.Float, nullable=True) grading = db.Column(db.Float, nullable=True) # semester data fields (update on new FTP files) -> whether the professor is teaching the given semester current_sem = db.Column(db.Boolean, nullable=False, default=False) next_sem = db.Column(db.Boolean, nullable=False, default=False) future_sem = db.Column(db.Boolean, nullable=False, default=False) # relationship fields user_courses = db.relationship('UserCourse', backref='prof', lazy=True) reviews = db.relationship('ProfReview', backref='prof', lazy=True) scheduled = db.relationship('ScheduledCourse', backref='prof', lazy=True) prof_course = db.relationship('ProfCourse', backref="prof", lazy=True) def __repr__(self): return f"Prof('{self.first_name} {self.last_name}')"
class User(db.Model): """ Class pertaining to a user of the website """ id = db.Column(db.Integer, primary_key=True) # user data fields first_name = db.Column(db.String(50), nullable=False) last_name = db.Column(db.String(50), nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) password_hash = db.Column(db.String(120)) verified = db.Column(db.Boolean, nullable=False) other_major = db.Column(db.String(50), nullable=True) # id fields major_id = db.Column(db.Integer, db.ForeignKey('dept.id')) profile_pic_id = db.Column(db.Integer, db.ForeignKey('profile_pic.id'), nullable=False) # relationship fields user_courses = db.relationship('UserCourse', backref='user', lazy=True) reviews_posted = db.relationship('Review', backref='author', lazy=True) course_reviews_liked = db.relationship('CourseReviewLiked', backref='user', lazy=True) course_reviews_disliked = db.relationship('CourseReviewDisliked', backref='user', lazy=True) prof_reviews_liked = db.relationship('ProfReviewLiked', backref='user', lazy=True) prof_reviews_disliked = db.relationship('ProfReviewDisliked', backref='user', lazy=True) def __repr__(self): v_str = ("" if self.verified else "Not ") + "Verified" return f"User('{self.first_name}', '{self.last_name}', '{self.email}', '{self.major}', '{v_str}')"
class Course(db.Model): """ Class corresponding to data for a course at UT Austin """ id = db.Column(db.Integer, primary_key=True) # course catalog data fields num = db.Column(db.String(6), nullable=False) title = db.Column(db.String(100), nullable=False) description = db.Column(db.Text, default="") restrictions = db.Column(db.Text, default="") pre_req = db.Column(db.Text, default="") # note: possible for a course to have a base topic but no further topics topic_num = db.Column(db.Integer, default=-1) # ecis fields # update on review submission/ecis update ecis_avg = db.Column(db.Float, nullable=True) ecis_students = db.Column(db.Integer, nullable=False, default=0) num_ratings = db.Column(db.Integer, default=0) approval = db.Column(db.Float, nullable=True) difficulty = db.Column(db.Float, nullable=True) usefulness = db.Column(db.Float, nullable=True) workload = db.Column(db.Float, nullable=True) # scheduled/semester fields -> True if the course is taught at the specified semester current_sem = db.Column(db.Boolean, nullable=False, default=False) next_sem = db.Column(db.Boolean, nullable=False, default=False) future_sem = db.Column(db.Boolean, nullable=False, default=False) # id fields topic_id = db.Column(db.Integer, db.ForeignKey('topic.id'), nullable=True) dept_id = db.Column(db.Integer, db.ForeignKey('dept.id'), nullable=False) # relationship fields user_courses = db.relationship('UserCourse', backref='course', lazy=True) reviews = db.relationship('CourseReview', backref='course', lazy=True) scheduled = db.relationship('ScheduledCourse', backref='course', lazy=True) prof_course = db.relationship('ProfCourse', backref="course", lazy=True) def __repr__(self): return f"Course('{self.dept.abr} {self.num}', '{self.title}')"
class Dept(db.Model): """ Class pertaining to a specific department at UT Austin (for courses) or fields of study (for students) """ id = db.Column(db.Integer, primary_key=True) # data fields abr = db.Column(db.String(3), nullable=False, unique=True) name = db.Column(db.String(75), nullable=False) college = db.Column(db.String(5), default='') dept = db.Column(db.String(4), default='') # relationship fields courses = db.relationship("Course", backref="dept", lazy=True) students = db.relationship("User", backref="major", lazy=True) def __repr__(self): return f"Dept(college='{self.college}', dept='{self.dept}', '{self.abr}', '{self.name}')"
class ProfilePic(db.Model): """ Class pertaining to a list of possible profile pictures for users to select at the front-end """ id = db.Column(db.Integer, primary_key=True) file_name = db.Column(db.String(20), unique=True, nullable=False) users = db.relationship('User', backref='pic', lazy=True) def __repr__(self): return f"ProfilePic('File Name: {self.file_name}')"