Example #1
0
class Feedback(BaseModel):
    __tablename__ = "feedback"
    feedback_id = db.Column(db.Integer, primary_key=True, nullable=False)
    username = db.Column(db.String(50), nullable=False)
    subject = db.Column(db.String(256), nullable=True)
    feedback_text = db.Column(db.String(256), nullable=False)

    def __init__(self, username, subject, feedback_text):
        self.username = username
        self.subject = subject
        self.feedback_text = feedback_text
Example #2
0
class Enrollment(BaseModel):
    __tablename__ = "enrollment"
    enrollment_id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(50),
                         db.ForeignKey('user.username'),
                         nullable=False)
    course_id = db.Column(db.String(50),
                          db.ForeignKey('course.course_id'),
                          nullable=False)

    course = db.relationship('Course')
    user = db.relationship('User')

    def __init__(self, username, course_id):
        self.username = username
        self.course_id = course_id
Example #3
0
class Section(db.Model):
    id = db.Column(db.Integer, primary_key=True, index=True)
    label = db.Column(db.String(150), nullable=False)
    article_id = db.Column(db.Text)
    order_number = db.Column(db.Integer)
    content_selection_method = db.Column(db.Text)
    wd_q_id = db.Column(db.String(20), nullable=False)
    lang_code = db.Column(db.String(7))
    quality = db.Column(db.String(25))
    retrieved_date = db.Column(db.Date,
                               nullable=False,
                               default=datetime.now().strftime('%Y-%m-%d'))

    def __repr__(self):
        # This is what is shown when object is printed
        return "Section({}, {}, {})".format(self.label, self.article_id,
                                            self.lang_code)
Example #4
0
class Domain(db.Model):
    id = db.Column(db.Integer, primary_key=True, index=True)
    domain_name = db.Column(db.Text, nullable=False)
    wikipedia_score = db.Column(db.Integer)
    wikipedia_domain = db.Column(db.Integer)
    search_result_score = db.Column(db.String(15))
    en_title = db.Column(db.Text)
    lang_code = db.Column(db.String(7))
    wd_q_id = db.Column(db.String(20))
    twitter_handle = db.Column(db.String(25))
    twitter_followers = db.Column(db.String(25))

    def __repr__(self):
        # This is what is shown when object is printed
        return "Domain({}, {}, {}, {}, {}, {}, {})".format(
            self.domain_name, self.wikipedia_score, self.wikipedia_domain,
            self.search_result_score, self.en_title, self.wd_q_id,
            twitter_followers)
Example #5
0
class User(BaseModel):
    __tablename__ = "user"
    #id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(50),
                         db.ForeignKey('user.username'),
                         primary_key=True,
                         nullable=False)
    password = db.Column(db.String(200), nullable=False)
    email = db.Column(db.String(256), nullable=False)
    first_name = db.Column(db.String(50), nullable=False)
    last_name = db.Column(db.String(50), nullable=False)
    type = db.Column(db.Enum("ADMIN", "REQUESTER", "TAKER"), nullable=False)
    approved = db.Column(db.Boolean)
    #Relationship A : 1 to many relationship between the user and matches tables
    #using the noterequestor's id, we find the notetakers matched

    #creates a collection of matches where the user in question is the notetaker
    #ie if you're a notetaker and you have 5 matches, then this will have those 5 match rows w/ this notetaker
    taker_matches = db.relationship('Matches',
                                    foreign_keys="Matches.notetaker_id")

    #creates a collection of matches where the user in question is the requester
    #ie if you're a requester and you have 5 notetakers for 5 diff classes, then this will have those 5 match rows w/ those notetakers
    requester_matches = db.relationship(
        'Matches', foreign_keys="Matches.noterequester_id")

    #Relationship B : 1 to many relationship between the user and enrollment tables
    enrollment = db.relationship('Enrollment', backref='User', lazy='dynamic')
    #__table_args__ = (db.UniqueConstraint("username", "id", name = "unique_username_id"),)

    files = db.relationship('File')

    def __init__(self, username, password, email, first_name, last_name, type,
                 approved):
        self.username = username
        self.password = generate_password_hash(password)
        self.email = email
        self.first_name = first_name
        self.last_name = last_name
        self.type = type
        self.approved = approved

    def check_password(self, password):
        return check_password_hash(self.password, password)
Example #6
0
class Statistics(db.Model):
    id = db.Column(db.Integer, primary_key=True, index=True)
    article_id = db.Column(db.Integer)
    created = db.Column(db.Boolean, nullable=True)
    sandbox = db.Column(db.Boolean, nullable=True)
    timestamp = db.Column(db.Date,
                          nullable=True,
                          default=datetime.now().strftime('%Y-%m-%d'))
    references_used = db.Column(
        db.String(500), nullable=False)  # Concatenation of the reference_ids
    sections_used = db.Column(
        db.String(25), nullable=False)  # Concatenation of the section_ids
    mobile = db.Column(db.Boolean, nullable=True)

    def __repr__(self):
        # This is what is shown when object is printed
        return "Statistics({}, {}, {}, {}, {}, {})".format(
            self.article_id, self.created, self.sandbox, self.timestamp,
            self.references_used, self.sections_used)
Example #7
0
class Article(db.Model):
    id = db.Column(db.Integer, primary_key=True, index=True)
    wd_item = db.Column(db.Text)
    name = db.Column(db.Text, nullable=False)
    wd_q_id = db.Column(db.String(20), nullable=False)
    lang_code = db.Column(db.String(7))
    domain = db.Column(db.Text)
    red_link = db.Column(db.Text)
    tag = db.Column(db.Text)
    category = db.Column(db.String(10))
    retrieved_date = db.Column(db.Date,
                               nullable=False,
                               default=datetime.now().strftime('%Y-%m-%d'))

    def __repr__(self):
        # This is what is shown when object is printed
        return "Article({}, {}, {}, {}, {})".format(self.name, self.wd_q_id,
                                                    self.lang_code,
                                                    self.domain, self.tag)
Example #8
0
class File(BaseModel):
    __tablename__ = "file"
    file_id = db.Column(db.String(256), primary_key=True, nullable=False)
    file_name = db.Column(db.String(256), nullable=False)
    timestamp = db.Column(db.DateTime, nullable=False)
    notetaker_id = db.Column(db.String(50),
                             db.ForeignKey('user.username'),
                             nullable=False)
    course_id = db.Column(db.String(50),
                          db.ForeignKey('course.course_id'),
                          nullable=False)

    notetaker = db.relationship('User', back_populates="files")
    course = db.relationship('Course')

    def __init__(self, file_id, file_name, timestamp, notetaker_id, course_id):
        self.file_id = file_id
        self.file_name = file_name
        self.timestamp = timestamp
        self.notetaker_id = notetaker_id
        self.course_id = course_id
Example #9
0
class Matches(BaseModel):
    __tablename__ = "matches"
    #id = db.Column(db.Integer, primary_key=True)
    match_id = db.Column(db.Integer, primary_key=True)
    notetaker_id = db.Column(db.String(50),
                             db.ForeignKey('user.username'),
                             nullable=False)
    noterequester_id = db.Column(db.String(50),
                                 db.ForeignKey('user.username'),
                                 nullable=False)
    course_id = db.Column(db.String(50),
                          db.ForeignKey('course.course_id'),
                          nullable=False)

    #Relationship specifying the course this match belongs to
    course = db.relationship('Course')
    #Links course to the course table, it knows that the above FK for course.course_id corresponds to this
    #so it will find the course w this course_id

    # Relationship specifying the note taker for this match
    notetaker = db.relationship('User',
                                foreign_keys=[notetaker_id],
                                back_populates="taker_matches")
    #Using the given notetaker_id, it goes into taker_matches (the table for all matches with the corresponding notetaker) in user to find
    #the notetaker in question

    # Relationship specifying the note requester for this match
    noterequester = db.relationship('User',
                                    foreign_keys=[noterequester_id],
                                    back_populates="requester_matches")

    #Using the given noterequester_id, goes to requester_matches and finds the user in question.

    #__table_args__ = (db.UniqueConstraint("username", "id", name = "unique_username_id"),)

    def __init__(self, notetaker_id, noterequester_id, course_id):
        self.notetaker_id = notetaker_id
        self.noterequester_id = noterequester_id
        self.course_id = course_id
Example #10
0
class Reference(db.Model):
    id = db.Column(db.Integer, primary_key=True, index=True)
    article_id = db.Column(db.Integer)
    section_id = db.Column(db.Integer)
    publisher_name = db.Column(db.Text)
    wd_q_id = db.Column(db.String(20), nullable=False)
    publication_title = db.Column(db.Text)
    lang_code = db.Column(db.String(7))
    summary = db.Column(db.Text)
    url = db.Column(db.Text)
    quality = db.Column(db.String(25))
    publication_date = db.Column(db.Date,
                                 nullable=False,
                                 default=datetime.now().strftime('%Y-%m-%d'))
    retrieved_date = db.Column(db.Date,
                               nullable=False,
                               default=datetime.now().strftime('%Y-%m-%d'))
    content_selection_method = db.Column(db.Text)

    def __repr__(self):
        # This is what is shown when object is printed
        return "Reference({}, {}, {}, {})".format(self.publisher_name,
                                                  self.publication_title,
                                                  self.summary, self.url)