<commit_before>[![Build Status](https://travis-ci.org/defivelo/db.svg?branch=master)](https://travis-ci.org/defivelo/db)

# L’Intranet Défi Vélo

Ce dépôt contient tout ce qui est nécessaire à faire tourner l’Intranet Défi Vélo.

Il a pour objectif de simplifier et améliorer la gestion des mois, sessions,
Qualifs, établissements, etc, et vise principalement à être utilisée par
les collaborateurs du Défi Vélo, aux différents échelons cantonaux et
inter-cantonaux.

## Local setup
1. Clone the project:

```
git clone --recursive <EMAIL>:swing/defivelo/intranet
```

2. Open the file `docker-compose.override.example.yml` and follow the instructions in it

3. Run the command `INITIAL=1 docker-compose up`

This will start the containers and set up the initial data. To access the site,
follow the instructions in the `docker-compose.override.example.yml` file.

Note the `INITIAL` flag should not be set for subsequent container starts unless
you want to reset the database.

## Roles & permissions
After adding a new permission in `defivelo/roles.py`, run the following in vagrant to apply them:
```
docker-compose exec backend bash
./manage.py sync_roles --reset_user_permissions
```

## Clone production database
```shell
docker-compose run backend fab prod import-db
```

## Automated tests

To run backend tests and lint checks, run `scripts/run_tests.sh` in the `backend` container:
* `docker-compose exec backend scripts/run_tests.sh`
* or `docker-compose run --rm backend scripts/run_tests.sh` if the `backend` service is not already running

CLI arguments are forwarded to `pytest`.
For example, running tests with `scripts/run_tests.sh defivelo --reuse-db` avoids
re-creating the database from scratch on each run.<commit_msg>DEFIVELO-215 Update Roles & permissions documentation<commit_after>[![Build Status](https://travis-ci.org/defivelo/db.svg?branch=master)](https://travis-ci.org/defivelo/db)

# L’Intranet Défi Vélo

Ce dépôt contient tout ce qui est nécessaire à faire tourner l’Intranet Défi Vélo.

Il a pour objectif de simplifier et améliorer la gestion des mois, sessions,
Qualifs, établissements, etc, et vise principalement à être utilisée par
les collaborateurs du Défi Vélo, aux différents échelons cantonaux et
inter-cantonaux.

## Local setup
1. Clone the project:

```
git clone --recursive <EMAIL>:swing/defivelo/intranet
```

2. Open the file `docker-compose.override.example.yml` and follow the instructions in it

3. Run the command `INITIAL=1 docker-compose up`

This will start the containers and set up the initial data. To access the site,
follow the instructions in the `docker-compose.override.example.yml` file.

Note the `INITIAL` flag should not be set for subsequent container starts unless
you want to reset the database.

## Roles & permissions
After adding a new permission in `defivelo/roles.py`, run the following inside docker to apply them:
```
docker-compose exec backend ./manage.py sync_roles --reset_user_permissions
```

## Clone production database
```shell
docker-compose run backend fab prod import-db
```

## Automated tests

To run backend tests and lint checks, run `scripts/run_tests.sh` in the `backend` container:
* `docker-compose exec backend scripts/run_tests.sh`
* or `docker-compose run --rm backend scripts/run_tests.sh` if the `backend` service is not already running

CLI arguments are forwarded to `pytest`.
For example, running tests with `scripts/run_tests.sh defivelo --reuse-db` avoids
re-creating the database from scratch on each run.
{'fraction_non_alphanumeric': 0.08703071672354949, 'fraction_numerical': 0.0031285551763367463, 'mean_word_length': 4.784539473684211, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4566026', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1075, 'n_words': 426}