Python wagtail.contrib.settings.models.BaseSetting() Examples

The following are 2 code examples of wagtail.contrib.settings.models.BaseSetting(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wagtail.contrib.settings.models , or try the search function .
Example #1
Source File: actions.py    From wagtail-graphql with MIT License 5 votes vote down vote up
def _add_setting(cls: Type[BaseSetting], node: str, dict_params: dict) -> Type[DjangoObjectType]:
    if not hasattr(cls, 'name'):    # we always need a name field
        cls.name = cls.__name__
    dict_params['Meta'].interfaces += (Settings,)
    tp = type(node, (DjangoObjectType,), dict_params)  # type: Type[DjangoObjectType]
    registry.settings[node] = (tp, cls)
    return tp 
Example #2
Source File: actions.py    From wagtail-graphql with MIT License 5 votes vote down vote up
def _register_model(registered: Set[type], cls: type, snippet: bool,
                    app: str, prefix: str, override_name=None) -> None:
    if cls in registered:
        return

    prefix = prefix.format(app=string.capwords(app),
                           cls=cls.__name__)
    node = override_name or prefix + cls.__name__

    # dict parameters to create GraphQL type
    class Meta:
        model = cls
        interfaces = (graphene.relay.Node, ) if RELAY else tuple()

    dict_params = {'Meta': Meta}

    # add streamfield handlers
    _add_streamfields(cls, node, dict_params, app, prefix)

    if snippet:
        _add_snippet(cls, node, dict_params)
    elif issubclass(cls, AbstractForm):
        _add_form(cls, node, dict_params)
    elif issubclass(cls, wagtailPage):
        _add_page(cls, node, dict_params)
    elif issubclass(cls, BaseSetting):
        _add_setting(cls, node, dict_params)
    else:  # Django Model
        _add_django_model(cls, node, dict_params)

    registered.add(cls)