from __future__ import annotations from django.conf import settings from django.db.models.signals import post_save from django.db import transaction from django.dispatch import receiver from .models import ProductModel, ProductVariant from .tasks import send_torob_product_webhook @receiver(post_save, sender=ProductModel) def notify_torob_product_save(sender, instance, **kwargs): if settings.TOROB_PRODUCT_WEBHOOK_TOKEN: transaction.on_commit(lambda: send_torob_product_webhook.delay([instance.id])) @receiver(post_save, sender=ProductVariant) def notify_torob_variant_save(sender, instance, **kwargs): if settings.TOROB_PRODUCT_WEBHOOK_TOKEN: transaction.on_commit(lambda: send_torob_product_webhook.delay([instance.product_id]))