# -*- coding: utf-8 -*-
from django.urls import include, path

from ocyan.core.plugins import OcyanPluginConfig
from ocyan.core.utils import merge_dicts


class BareboneConfig(OcyanPluginConfig):
    def contribute_to_settings(self, settings):
        return merge_dicts(
            settings,
            {
                "OSCAR_REQUIRED_ADDRESS_FIELDS": [
                    "first_name",
                    "last_name",
                    "line1",
                    "house_number",
                    "line4",
                    "postcode",
                    "country",
                    "email",
                ],
                "OSCAR_DYNAMIC_CLASS_LOADER": "ocyan.main.loading.ocyan_class_loader",
            },
            overwrite=False,
        )

    def contribute_to_urlpatterns(self, urlpatterns):
        return [path("", include("ocyan.plugin.barebone.urls"))] + urlpatterns

    def contribute_to_installed_apps(self, installed_apps):
        installed_apps.django.append("django.contrib.sitemaps")
        installed_apps.apps.append("sorl.thumbnail")
        installed_apps.apps.append("widget_tweaks")
        installed_apps.front.append("ocyan.plugin.barebone", extends="oxyan.themes")
        return installed_apps
