__get_model_config.py 636 Bytes
Newer Older
1
from shared import load_api_config
2
3


Florent Chehab's avatar
Florent Chehab committed
4
def get_model_config(model):
5
    api_config = load_api_config()
6
7

    for obj in api_config:
8
9
        if "is_api_view" in obj and obj["is_api_view"]:
            continue
10
        if obj["model"] == model:
11
            tmp = {
Florent Chehab's avatar
Florent Chehab committed
12
                "moderation_level": obj["moderation_level"],
13
                "model": model,
14
                "read_only": obj["read_only"],
Florent Chehab's avatar
Florent Chehab committed
15
            }
16
            key = "enforce_moderation_user_level"
17
18
19
            if key in obj.keys():
                tmp[key] = obj[key]
            return tmp
20

Florent Chehab's avatar
Florent Chehab committed
21
    raise Exception("Model not found in API configuration, cannot process !")