get_api_config.py 666 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
import yaml
from os.path import join, realpath, dirname


def get_api_config():
    current_dir = dirname(realpath(__file__))
    with open(join(current_dir, 'api_config.yml'), 'r') as f:
        api_config = yaml.load(f)

    # clean api_config (add default arguments)
    DEFAULT_SETTINGS = {
        "ignore_in_admin": False,
        "requires_testing": False,
Florent Chehab's avatar
Florent Chehab committed
14
15
        "moderation_level": 2,
        "versionned": False,
16
17
        "read_only": False,
        "viewset_permission": 'default'
18
19
20
21
22
23
24
25
    }

    for obj in api_config:
        for key in DEFAULT_SETTINGS:
            if key not in obj:
                obj[key] = DEFAULT_SETTINGS[key]

    return api_config