config_files.md 3.19 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Words relative to *config files*
=========

<!-- This file is referenced in the config_files, if you modify its location, please update those files too. -->

## Django config files

!> TODO


## Custom config files

To centralize the definition of certain certain Models and (all) ViewSets attributes, we centralized a lot of information in few configuration files. Some of those files are also read at compile time when the frontend is built to automatically generate the required `Redux` actions and reducers.

!> TODO more on actions and reducers for the frontend.

Below is the documentation about those files.

*NB: all those files use the `yaml` syntax.*


### defaults.yaml

Contains default values, nothing special to say here.


### viewsets_config.yml

This file contains the configuration of the (all) the app viewsets. It has a key/value structure with key the ViewSet name.

Each viewset has the following required required attributes:

* `api_end_pont`: it is the main part of the url for making request to the api. This string will also be used for naming variables in JS, so keep it simple and consistent please. :smile:
* `import_location`: in what file path (dot like notation) is the viewset available ? You should only specify the part that comes after `backend_app.models.`. *NB: the associated model should be available from the same path.*


There can also be optional parameters:

* :warning: `viewset_permission` (defaults to `(IsAuthenticated & (IsStaff | NoDelete))`): What are the permissions associated with each viewset. If something is specified then it will be composed (`&`) with the default one. You can compose permissions with `&` (logical *and*) or `|` (logical *or*). All the available permissions are listed in the `__get_viewset_permissions.py` file. You can also create your own.
* `api_attr` (defaults to `None`): to specify some attributes that may be captured and used in the viewset (eg: `(?P<content_type_id>[0-9]+)/(?P<object_pk>[0-9A-Za-z]+)`)
* `requires_testing` (defaults to `false`): boolean to tell if this viewset is only available in a testing environment, for testing purposes.
* `is_api_view` (defaults to `false`): Boolean to tell if the viewset is an API View (a viewset that is not tied to django model).
* `api_name` (defaults to `None`): If you have a custom `get_queryset` function in your viewset, you need to specify an

If no value is taken, then the default one is added in the `load_viewsets_config` function (in `backend/backend_app/config/utils.py`).


### models_config.yml

This file contains the configuration of the app models. It has a key/value structure with key the model name.

For now, there is only one attribute which can be set: `moderation_level`. This attribute tells how moderation should be applied to each model.

Moderation levels are defined as follow :

* `0` : moderation will never be applied,
* `1` : moderation will be on if the global settings for moderation is turned on,
* `2` : (default for security reasons) moderation will always be on no matter what.

*NB: staff members, dri members and moderators won't be subject to moderation.*

*NB: moderation can be moreover enforced at the object level. But that's for another documentation part.*

!> TODO doc about this.