Skip to content
This repository has been archived by the owner on Jul 27, 2024. It is now read-only.

Latest commit

 

History

History
94 lines (63 loc) · 3.74 KB

README.md

File metadata and controls

94 lines (63 loc) · 3.74 KB

Closure()

CodeFactor Backend CI Backend CI

Planning your next courses easily.

About

This project is part of the Open Source Software Workshop at the Hebrew University of Jerusalem.

Table of Contents

  1. Clone this repo.
  2. Run python3 -m venv venv to install a new Python virtual environment.
  3. 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.
  4. Run pip install --upgrade pip
  5. Run pip install -r requirements.txt to install the project's dependencies.
  6. Run python Closure_Project/manage.py migrate
  7. On PyCharm, right-click the outer Closure_Project directory, choose Mark Directory as and click Sources Root (its icon will be colored cyan afterwards).
  8. 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.

Upon migrating the database, a data dump containing all parsed course and track data will be downloaded from the internet and inserted into the database.

You can run all tests by running pytest (while in a virtual environment) at the Closure_Project folder.

Note that a test database will be automatically created for DB tests, and it will undergo all migrations by default. While this is good in terms of testing the migrations themselves, it can be annoyingly slow during development.

You can disable migrations during testing by uncommenting ; addopts = --no-migrations within the Closure_Project/pytest.ini file, this way the test database schemas will be generated based on the model's metadata. If you do so, make sure not to commit this change into the repository, as the CI tests migrations indirectly by running the DB models.

  1. If you don't have admin superuser, creat one with python Closure_Project/manage.py createsuperuser
  2. 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.

Note that if you change the backend models, you should commit the resulting migration along with the changed models. You can generate migrations by doing python manage.py makemigrations rest_api within the Closure_Project folder.