# -*- coding: utf-8 -*-
from ocyan.core.fender import config
from ocyan.core.plugins import OcyanPluginConfig
from ocyan.core.utils import merge_dicts


class CarbasaConfig(OcyanPluginConfig):
    def contribute_to_installed_apps(self, installed_apps):
        installed_apps.front.append("ocyan.plugin.carbasa")
        installed_apps.front.register_extension("ocyan.plugin.carbasa", "oxyan.themes")
        installed_apps.wagtail.register_extension(
            "ocyan.plugin.carbasa", "ocyan.plugin.coyote"
        )

        if config.is_webshop:  # enable the webshop extension
            installed_apps.front.register_extension(
                "ocyan.plugin.carbasa.webshop", "oxyan.themes"
            )
            installed_apps.front.register_extension(
                "ocyan.plugin.carbasa.webshop", "ocyan.plugin.carbasa"
            )
            installed_apps.front.register_extension(
                "ocyan.plugin.carbasa.webshop", "ocyan.plugin.coyote.oxyan_extension"
            )
            installed_apps.wagtail.register_extension(
                "ocyan.plugin.carbasa.webshop",
                "ocyan.plugin.wagtail_oscar_integration.wagtail_oscar_integration_coyote_extension",
            )
        else:
            installed_apps.front.register_extension(
                "ocyan.plugin.carbasa", "ocyan.plugin.barebone"
            )

        return installed_apps

    def contribute_to_settings(self, settings):
        return merge_dicts(
            settings,
            {
                "OXYAN_HEADER_OPTIONS": [
                    ("basic", "Basic Header"),
                    ("big", "Big Header"),
                    ("mega", "Mega Header"),
                ],
            },
            overwrite=True,
        )
