Planning your next courses easily.
This project is part of the Open Source Software Workshop at the Hebrew University of Jerusalem.
- Clone this repo.
- Run
python3 -m venv venv
to install a new Python virtual environment. - Activate the virtual environment so your commands will be executed inside a virtual environment:
- Windows: run
venv\Scripts\activate.bat
. - Mac OS/Linux: run
source venv/bin/activate
.
- Windows: run
- Run
pip install -r requirements.txt
to install the project's dependencies. - Run
python Closure_Project/manage.py makemigrations rest_api
- Run
python Closure_Project/manage.py migrate
- On PyCharm, right-click the outer
Closure_Project
directory, chooseMark Directory as
and clickSources Root
(its icon will be colored cyan afterwards). - Start the Django server with
python Closure_Project/manage.py runserver
You now have a django instance with the database configured (yet blank).
The next step would be populating the database with Course
information, so the whole ordeal
can work.
See the Parser
folder, or read the following subsection to learn more about the data
structures used.
The Hebrew University of Jerusalem serves course information as follows:
- Course details provide everything to be known regards courses: points given, teachers, course schedule etc.
- Track data shows which courses are required or available on each study-track
- Corner-Stone courses are listed on the program website, only available in Hebrew. (These are required courses in topics unrelated to one's study program or topic)
Note:
- It is important to parse courses before parsing tracks. When parsing a track, the parser validates the relevant courses already exist in the database.
- The example parser provided in the
Parser
folder is configured to fetch and parse information from the Hebrew versions of the said websites.
To download the course files, run the Parser/MoonDownloader.py
file (make sure venv is activated!). The folders tracks_html
and course_details_html
will be created.
Downloading will take time! (the moon website is...fragile)
In case of network issues when downloading (or, to save yourself time), it's possible to load the data of all courses and tracks.
- Download the 7z dump file (HUJI account required)
- Extract it into the
Parser
folder - Run
OfflineParser.py -> load_all_dumped()
(Tip: if fetching corner-stone coursers gets stuck, comment out that line and continue with out that data, there's an open issue)
Once you have both folders populated, run Parser/OfflineParser.py
.
Parsing happens in the following order:
- Parsing course details, parsed data is stored in
parsed_courses.json
- Parsing data relevant for the
Track
andCourseGroup
objects. parsed data is stored in folders namedparsed_tracks
andparsed_groups
as json files. - Loading the parsed course data as
Models.Course
objects in the Django database. - Fetching CornerStone course information (course id only), and marking relevant
Course
objects asis_corner_stone = True
(None by default) - Loading the parsed Track data as
Models.Track
objects in the Django database. - Loading the parsed
CourseGroup
data asModels.CourseGroup
objects in the Django database.
The aforementioned order is important, as some objects assume existence of others (e.g. CourseGroup
and Course
objects).
- If you don't have admin superuser, creat one with
python Closure_Project/manage.py createsuperuser
- Use basic authentication with your username and password created, or generate token with
python Closure_Project/manage.py drf_create_token
and add{Autharization: Token <key>}
to request headers.
-
To use the API, start the server with
python Closure_Project/manage.py runserver
. -
The base API url is
https://<host>/api/v1
. -
API documentation is available in
https://<host>/redoc/
-
Try to use API with:
https://<host>/swagger/
-
When making real requests, always remember to add the Authorization header to the request.
Feel free to PR or open issues.