Exemple #1
0
 def resynchronize(self, request, queryset):  # pylint:disable=unused-argument
     """
     Synchronizes the sent products with the product advertising api.
     :param request: sent request
     :param queryset: queryset containing the products
     """
     from price_monitor.product_advertising_api.tasks import SynchronizeProductsTask
     for product in queryset:
         SynchronizeProductsTask.delay([product.asin])
 def resynchronize(self, request, queryset):  # pylint:disable=unused-argument
     """
     Synchronizes the sent products with the product advertising api.
     :param request: sent request
     :param queryset: queryset containing the products
     """
     from price_monitor.product_advertising_api.tasks import SynchronizeProductsTask
     for product in queryset:
         SynchronizeProductsTask.delay([product.asin])
def synchronize_product_after_creation(sender, instance, created, **kwargs):  # pylint:disable=unused-argument
    """
    Directly start synchronization of a Product after its creation.

    :param sender: class calling the signal
    :type sender: ModelBase
    :param instance: the Product instance
    :type instance: Product
    :param created: if the Product was created
    :type created: bool
    :param kwargs: additional keywords arguments, see https://docs.djangoproject.com/en/dev/ref/signals/#django.db.models.signals.post_save
    :type kwargs: dict
    """
    if created and os.environ.get('STAGE', 'Live') != 'TravisCI':
        from price_monitor.product_advertising_api.tasks import SynchronizeProductsTask
        # have to delay the creation a when using angular via API somehow the product is not fully saved when the task is run thus it does not find the product
        SynchronizeProductsTask.apply_async(([instance.asin],), countdown=1)