#70 Add endpoint to create content
This commit is contained in:
@@ -77,6 +77,7 @@ class Course(db.Model):
|
||||
instructor = sa.Column(sa.ForeignKey(User.id), index=True)
|
||||
created_at = sa.Column(sa.DateTime)
|
||||
assignments = db.relationship("Assignment", backref="course", lazy="dynamic")
|
||||
content = db.relationship("Content", backref="course", lazy="dynamic")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<Course {self.course_code}>"
|
||||
@@ -130,7 +131,7 @@ class Content(db.Model):
|
||||
created_at = sa.Column(sa.DateTime)
|
||||
|
||||
def from_dict(self, data) -> None:
|
||||
for field in ["name", "body"]:
|
||||
for field in ["name", "body", "course_id"]:
|
||||
if field in data:
|
||||
setattr(self, field, data[field])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user