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 Semester(db.Model): """ Course pertaining to a given school semester for UT Austin """ id = db.Column(db.Integer, primary_key=True) # data fields year = db.Column(db.Integer, nullable=False) semester = db.Column(db.Integer, nullable=False) # relationship fields user_courses = db.relationship('UserCourse', backref='semester', lazy=True) reviews = db.relationship("Review", backref="semester", lazy=True) scheduled_courses = db.relationship("ScheduledCourse", backref="semester", lazy=True) prof_course_sem = db.relationship('ProfCourseSemester', backref="semester", lazy=True) def __repr__(self): return f"Semester({self.year}{self.semester})"
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 ProfCourseSemester(db.Model): """ Class used to map relationships between prof_course and semester. This is used to map what professors taught across the different semesters at UT, the unique number, and the ecis score. """ id = db.Column(db.Integer, primary_key=True) unique_num = db.Column(db.Integer) prof_course_id = db.Column(db.Integer, db.ForeignKey('prof_course.id'), nullable=False) sem_id = db.Column(db.Integer, db.ForeignKey('semester.id'), nullable=False) ecis = db.relationship("EcisScore", backref="profcoursesemester", lazy=True)
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}')"
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 ProfCourse(db.Model): """ Class used to map relationships between professors and courses that shows what professors teaches what course """ id = db.Column(db.Integer, primary_key=True) prof_id = db.Column(db.Integer, db.ForeignKey('prof.id'), nullable=False) course_id = db.Column(db.Integer, db.ForeignKey('course.id'), nullable=False) prof_course_sem = db.relationship('ProfCourseSemester', backref="prof_course", lazy=True) def __repr__(self): return f"""ProfCourse(
class Topic(db.Model): """ Class containing list of courses corresponding to the same topic group """ id = db.Column(db.Integer, primary_key=True) courses = db.relationship("Course", backref="topic", lazy=True) def __repr__(self): parent_topic = "" for course in self.courses: if course.topic_num == 0: parent_topic = course.title return f"Topic('{parent_topic}')"
class CrossListed(db.Model): """ Class containing list of ScheduledCourse objects that are cross-listed """ id = db.Column(db.Integer, primary_key=True) courses = db.relationship('ScheduledCourse', backref='xlist', lazy=True) def __repr__(self): repr_strs = [] for course in self.courses: repr_strs.append(f"'{course.dept.abr} {course.num}'") repr_str = ', \n'.join(repr_strs) return f"""CrossListed(