__get_model_config.py 671 Bytes
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
from shared import get_api_objs
2 3


Florent Chehab's avatar
Florent Chehab committed
4 5 6 7 8 9 10 11
def get_model_config(model: str) -> dict:
    """
    Returns the configuraiton of the model
    """
    for obj in get_api_objs(has_model=True, is_api_view=False, make_imports=False):
        if obj.model == model:
            out = {
                "moderation_level": obj.moderation_level,
12
                "model": model,
Florent Chehab's avatar
Florent Chehab committed
13
                "read_only": obj.read_only,
Florent Chehab's avatar
Florent Chehab committed
14
            }
15
            key = "enforce_moderation_user_level"
16
            if key in obj.keys():
Florent Chehab's avatar
Florent Chehab committed
17 18
                out[key] = obj[key]
            return out
19

Florent Chehab's avatar
Florent Chehab committed
20 21 22
    raise Exception(
        "Model {} not found in API configuration, cannot process !".format(model)
    )