Skip to content

Commit

Permalink
Adjusted "toJSON" method of Course
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian-Schaefer committed Jul 29, 2022
1 parent 89214ef commit d8113e4
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,20 @@ def toJSON(self) -> Dict:
:return: A Course serialized as JSON
:rtype: Dict
"""
competencies_json = [
competency.toJSON() for competency in self.competencies
]
if self.competencies:
competencies_json = [
competency.toJSON() for competency in self.competencies
]

return {
"id": self.id,
"description": self.description,
"extractor": self.extractor,
"competencies": competencies_json,
}

return {
"id": self.id,
"description": self.description,
"extractor": self.extractor,
"competencies": competencies_json,
}

0 comments on commit d8113e4

Please sign in to comment.