コード例 #1
0
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)
コード例 #2
0
ファイル: user.py プロジェクト: KiboNaku/utreview-backend
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}')"
コード例 #3
0
ファイル: user.py プロジェクト: KiboNaku/utreview-backend
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}')"
コード例 #4
0
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(
コード例 #5
0
class EcisScore(db.Model):
    """
    Class to contain ECIS data for given professor, course, semester, and unique_number
    """
    id = db.Column(db.Integer, primary_key=True)

    course_avg = db.Column(db.Float, nullable=False)
    prof_avg = db.Column(db.Float, nullable=False)
    num_students = db.Column(db.Integer, nullable=False)

    prof_course_sem_id = db.Column(db.Integer,
                                   db.ForeignKey('prof_course_semester.id'),
                                   nullable=False)

    def __repr__(self):
        return f"""EcisScore(
コード例 #6
0
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})"
コード例 #7
0
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}')"
コード例 #8
0
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}')"
コード例 #9
0
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(
コード例 #10
0
class UserCourse(db.Model):
    """
    Class corresponding to a course that a user took in a given semester
    """
    id = db.Column(db.Integer, primary_key=True)

    unique_num = db.Column(db.Integer, nullable=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=True)
    course_id = db.Column(db.Integer,
                          db.ForeignKey('course.id'),
                          nullable=True)
    prof_id = db.Column(db.Integer, db.ForeignKey('prof.id'), nullable=True)
    semester_id = db.Column(db.Integer,
                            db.ForeignKey('semester.id'),
                            nullable=True)
コード例 #11
0
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(
コード例 #12
0
ファイル: prof.py プロジェクト: KiboNaku/utreview-backend
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}')"
コード例 #13
0
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}')"