#10 Create assignment model
This commit is contained in:
@@ -58,7 +58,7 @@ class User(UserMixin, db.Model):
|
||||
"id": self.id,
|
||||
"username": self.username,
|
||||
"email": self.email,
|
||||
"role": self.role
|
||||
"role": self.role,
|
||||
}
|
||||
|
||||
def from_dict(self, data, new_user=False) -> None:
|
||||
@@ -76,6 +76,7 @@ class Course(db.Model):
|
||||
description = sa.Column(sa.Text, index=True)
|
||||
instructor = sa.Column(sa.ForeignKey(User.id), index=True)
|
||||
created_at = sa.Column(sa.DateTime)
|
||||
assignments = db.relationship("Assignment", backref="course", lazy="dynamic")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<Course {self.course_code}>"
|
||||
@@ -95,3 +96,11 @@ class Course(db.Model):
|
||||
|
||||
d["instructor"] = User.query.get(self.instructor).username
|
||||
return d
|
||||
|
||||
|
||||
class Assignment(db.Model):
|
||||
id = sa.Column(sa.Integer, primary_key=True)
|
||||
name = sa.Column(sa.String(128), index=True)
|
||||
course_id = sa.Column(sa.ForeignKey(Course.id), index=True)
|
||||
description = sa.Column(sa.Text, index=True)
|
||||
created_at = sa.Column(sa.DateTime)
|
||||
|
||||
Reference in New Issue
Block a user