from django.conf import settings
from django.utils.translation import gettext as _
from django.utils.translation import override

from oscar.core.loading import get_model

from . import constants


def create_shipping_event(sender, app_config, **kwargs):  # pylint: disable=W0613
    "Make sure the shipping events exist"
    ShippingEventType = get_model("order", "ShippingEventType")

    with override(settings.LANGUAGE_CODE):
        ShippingEventType.objects.get_or_create(
            code=constants.SHIPPING_EVENT_SHIPPED, defaults={"name": _("Shipped")}
        )
