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


class OcyanOscar3PartnerAppPluginConfig(OcyanPluginConfig):
    def contribute_to_settings(self, settings):
        return merge_dicts(
            settings,
            {
                "OCYAN_PARTNER_RELATIVE_PRICE": True,
                "OCYAN_PARTNER_EU_VAT_RULES_ACTIVATED": True,
                "MIGRATION_MODULES": {
                    "partner": "ocyan.plugin.oscar_partner.oxyan_partner_extension.migrations"
                },
            },
        )

    def contribute_to_installed_apps(self, installed_apps):
        installed_apps.ocyan.append("ocyan.plugin.oscar_partner")
        installed_apps.oscar.append(
            "ocyan.plugin.oscar_partner.partner.apps.PartnerConfig",
            replaces="oscar.apps.partner.apps.PartnerConfig",
        )
        installed_apps.oscar.register_extension(
            "ocyan.plugin.oscar_partner.oxyan_partner_extension",
            "ocyan.plugin.oscar_partner.partner",
        )
        return installed_apps
