Skip to content

This is the backend of Projects, a website developed by the Learning Planet Institute.

License

Notifications You must be signed in to change notification settings

CyberCRI/projects-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CC BY-NC-SA 4.0

projects-backend

https://projects.directory.com Code style: black

Requirements

  • Docker Compose V2

Usage

Clone the repository

git clone --recurse-submodules git@github.com:CyberCRI/projects-backend.git 
cd projects-backend

Set up your environment variables

if you want to set your environnement variables (Mostly third-parties secrets):

cp .env.example .env

You can ask the other devs for the secret values to fill the .env file.

Run the stack

docker compose up

The backend and Celery restart multiple times because they keep crashing while Keycloak is not up. After a short moment, your backend will be up and ready.

You can now access:

Execute into the backend container

The stack need to be running. Get a shell access to the backend container

make bash

Migrate the database

# inside the container
python manage.py migrate

Collect static files

# inside the container
python manage.py collectstatic

Compile translations

# inside the container
python manage.py compilemessages

Default user

A default superadmin is created in keycloak. To import it in Projects, you need to login at least once in the swagger or in Django admin using these credentials:

  • username: admin or admin@localhost.com
  • password: admin

You can also use these credentials (use the admin username, not the email) to connect to the Keycloak admin panel

Run test

Run all the tests:

# inside the container
make test

Run just one test file or test directory:

# inside the container
# ex:path_to_file=apps.accounts.tests.views.test_people_group
python manage.py test <path_to_file> --settings=projects.settings.test 

Continuous Integration

You can check locally that the CI will validate your pull request by running the following commands in your backend container. Your pull request cannot be merged if it doesn't meet these requirements. You can run these tests locally before asking to merge your PR, or you can let the CI run them for you remotely.

  1. Respect format rules:
# inside the container
make format

This will automatically update your files

  1. Respect lint rules:
# inside the container
make lint

This will return errors that you need to fix manually. If there are some, fix them then repeat step 1.

  1. Keep translations up to date:
# inside the container
make makemessages

This will detect changes in translated messages. Even if you didn't add, remove or modify any translated message. This might update some files because of line changes on translations caused by your changes.

If there are new messages, be sure to add the translation after running this command.

  1. Create migrations if needed:
# inside the container
python manage.py makemigrations
  1. Be sure that all tests pass
# inside the container
make test

License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

CC BY-NC-SA 4.0

About

This is the backend of Projects, a website developed by the Learning Planet Institute.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages