from django.utils.translation import gettext_lazy as _

from oscar.apps.customer.alerts.utils import (
    AlertsDispatcher as BaseAlertsDispatcher,
)

from ocyan.main.loading import get_ocyan_class

get_default_site = get_ocyan_class("wagtail_utils.utils", "get_default_site")
get_offline_request = get_ocyan_class("wagtail_utils.utils", "get_offline_request")


class AlertsDispatcher(BaseAlertsDispatcher):
    def get_extra_context(self, alert):
        context = super().get_extra_context(alert)
        site = get_default_site()
        context["request"] = get_offline_request(site.domain)
        return context
