from .utils import exclude_none_values


def get_style_settings():
    from wagtail.models import Site

    from ocyan.plugin.wagtail.middleware import get_current_request

    from ocyan.plugin.coyote.models import StyleSettings

    request = get_current_request()

    if request is not None:
        if not hasattr(request, "style_settings"):
            request.style_settings = StyleSettings.for_request(request)

        return request.style_settings

    else:
        return StyleSettings.for_site(Site.objects.get(is_default_site=True))


def get_coyote_definitions():
    style = get_style_settings()
    return exclude_none_values(style.definitions)
