Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.

Commit

Permalink
Angga/enrich courses data for ulas kelas (#5)
Browse files Browse the repository at this point in the history
* feat: scrape desc and prereq

* feat: enrich serialize course

* feat: handle max len desc

* feat: finish scrape desc and prereq

* feat: create endpoint and enhance scraping

Co-authored-by: Muhammad Erlangga <[email protected]>
  • Loading branch information
angga1518 and Muhammad Erlangga authored Sep 10, 2021
1 parent 4959067 commit e564860
Show file tree
Hide file tree
Showing 3 changed files with 227 additions and 202 deletions.
13 changes: 13 additions & 0 deletions backend/app/views/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,16 @@ def scrap_all_schedule():
password=password
)
return jsonify(response), status_code

@router_main.route('/courses', methods=['GET'])
def get_all_courses():
active_period = get_app_config("ACTIVE_PERIOD")
period = Period.objects(
name=active_period
).first()
all_courses = []
for course in period.courses:
all_courses.append(course.serialize_ulas_kelas())
return (jsonify({
'courses': all_courses
}), 200)
12 changes: 9 additions & 3 deletions backend/models/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,24 @@ def __get_classes(self):
return data

def serialize(self):
return {
"name": self.name,
"credit": self.credit,
"term": self.term,
"classes": self.__get_classes()
}

def serialize_ulas_kelas(self):
return {
"name": self.name,
"credit": self.credit,
"code": self.course_code,
"curriculum": self.curriculum,
"description": self.description,
"prerequisite": self.prerequisite,
"term": self.term,
"classes": self.__get_classes()
"term": self.term
}


class Period(mongo.Document):
major_id = mongo.ReferenceField("Major")
name = mongo.StringField(max_length=16)
Expand Down
Loading

0 comments on commit e564860

Please sign in to comment.