# import logging
# from io import BytesIO

# from django.db.models.signals import post_save
# from django.dispatch import receiver

# from core import TransactionStatus
# from core.models import Order, Transaction
# from .tasks import send_order_confirmation_email

# logger = logging.getLogger(__name__)

# @receiver(post_save, sender=Order, dispatch_uid="order_created")
# def order_created(sender, instance, created, **kwargs):
#     if created:
#         logger.info("Order was created")
#         Transaction.objects.create(order=instance)


# @receiver(post_save, sender=Transaction, dispatch_uid="transaction_created")
# def transaction_created(sender, instance, created, **kwargs):
#     if created:
#         logger.info("Transaction was created")

#     elif instance.status == TransactionStatus.COMPLETED:
#         order = {
#             'order_id': instance.order.pk,
#             'email': instance.order.customer.email,
#             'full_name': instance.order.customer.get_full_name()
#         }
#         send_order_confirmation_email.delay(order)
