Beispiel #1
0
def handle_product_post_save(sender, instance, **kwargs):
    bump_product_signal_handler(sender, instance, **kwargs)
    bump_prices_for_product(instance)

    for shop_id in set(instance.shop_products.all().values_list("shop_id",
                                                                flat=True)):
        context_cache_item_bumped.send(sender=Shop, shop_id=shop_id)
Beispiel #2
0
def handle_shop_product_post_save(sender, instance, **kwargs):
    if isinstance(instance, Category):
        bump_shop_product_signal_handler(sender, instance.shop_products.all().values_list("pk", flat=True), **kwargs)

        for shop_id in set(instance.shop_products.all().values_list("shop_id", flat=True)):
            bump_prices_for_shop_product(shop_id)
            context_cache_item_bumped.send(sender=Shop, shop_id=shop_id)
    else:  # ShopProduct
        bump_shop_product_signal_handler(sender, instance, **kwargs)
        bump_prices_for_shop_product(instance.shop_id)
        context_cache_item_bumped.send(sender=Shop, shop_id=instance.shop_id)
Beispiel #3
0
def bump_cache_for_item(item):
    """
    Bump cache for given item

    Use this only for non product items. For products
    and shop_products use `bump_cache_for_product` and
    `bump_cache_for_shop_product` for those.

    :param item: Cached object
    """
    cache.bump_version(_get_namespace_for_item(item))
    context_cache_item_bumped.send(getattr(item, "__class__", item), item=item)
Beispiel #4
0
def bump_cache_for_item(item):
    """
    Bump cache for given item

    Use this only for non product items. For products
    and shop_products use `bump_cache_for_product` and
    `bump_cache_for_shop_product` for those.

    :param item: Cached object
    """
    cache.bump_version(_get_namespace_for_item(item))
    context_cache_item_bumped.send(getattr(item, "__class__", item), item=item)
Beispiel #5
0
def bump_cache_for_item_ids(item_ids, namespace, object_class, shop=None):
    """
    Bump cache for given item ids

    Use this only for non product items. For products
    and shop_products use `bump_cache_for_product` and
    `bump_cache_for_shop_product` for those.

    :param ids: list of cached object id's
    """
    for item_id in item_ids:
        cache.bump_version("{}-{}".format(namespace, item_id))
        context_cache_item_bumped.send(object_class, item=item_id, shop=shop)