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


class OcyanOscar3CatalogueAppPluginConfig(OcyanPluginConfig):
    def get_smoketest_modules(self):
        return ["ocyan.plugin.oscar_catalogue.tests"]

    def contribute_to_settings(self, settings):
        return merge_dicts(
            settings,
            {
                "MIGRATION_MODULES": {
                    "catalogue": "ocyan.plugin.oscar_catalogue.oxyan_catalogue_extension.migrations"
                }
            },
        )

    def contribute_to_installed_apps(self, installed_apps):
        installed_apps.oscar.append(
            "ocyan.plugin.oscar_catalogue.catalogue.apps.CatalogueConfig",
            replaces="oscar.apps.catalogue.apps.CatalogueConfig",
        )
        installed_apps.oscar.register_extension(
            "ocyan.plugin.oscar_catalogue.oxyan_catalogue_extension",
            "ocyan.plugin.oscar_catalogue.catalogue",
        )
        installed_apps.ocyan.append("ocyan.plugin.oscar_catalogue")
        return installed_apps

    def contribute_to_i18n_fields(self, fields_dict):
        fields_dict = super().contribute_to_i18n_fields(fields_dict)
        fields_dict.update(
            {
                "catalogue.product.long_description": True,
                "catalogue.product.meta_title": False,
                "catalogue.product.meta_description": False,
                "catalogue.category.meta_title": False,
                "catalogue.category.meta_description": False,
            }
        )
        return fields_dict
