from oscar.apps.communication import managers as oscar
from oscar.core.loading import get_class

EmailContext = get_class("order.context", "EmailContext")


class CommunicationTypeManager(oscar.CommunicationTypeManager):
    def get_and_render(self, code, context):
        if isinstance(context, EmailContext):
            return super().get_and_render(code, context)

        return super().get_and_render(code, EmailContext(**context))
