Exemplo n.º 1
0
def update_webapp_product_model_properties_cache(**kwargs):
    """
    更新product model缓存
    """
    if cache.request.user_profile:
        webapp_owner_id = cache.request.user_profile.user_id
        key = 'webapp_product_model_properties_{wo:%s}' % webapp_owner_id
        cache_util.delete_cache(key)
Exemplo n.º 2
0
def update_webapp_product_detail_by_review_cache(**kwargs):
    if hasattr(cache, 'request'):
        webapp_owner_id = cache.request.user_profile.user_id
        product_id = None
        instance = kwargs.get('instance', None)
        if instance:
            product_id = instance[0].product_id

        if product_id:
            key = 'webapp_product_detail_{wo:%s}_{pid:%s}' % (webapp_owner_id,
                                                              product_id)
            cache_util.delete_cache(key)
Exemplo n.º 3
0
def update_webapp_product_model_cache(**kwargs):
    model = kwargs.get('instance', None)
    if model and model[0].stocks < 1:
        model = model[0]
        key = 'webapp_product_detail_{wo:%s}_{pid:%s}' % (model.owner_id,
                                                          model.product_id)
        cache_util.delete_cache(key)

        if model.owner_id != 216:
            key = 'webapp_product_detail_{wo:216}_{pid:%s}' % (
                model.product_id)
            cache_util.delete_cache(key)
Exemplo n.º 4
0
def update_webapp_product_detail_cache_by_promotion(instance, **kwargs):
    """
    根据促销信息,更新商品详情
    """
    if not hasattr(cache, 'request'):
        # 不是后台web系统的update,直接返回
        return

    webapp_owner_id = cache.request.user_profile.user_id
    if isinstance(instance, promotion_models.Promotion):
        promotion_ids = [instance.id]
    else:
        promotion_ids = [promotion.id for promotion in instance]
    for p in promotion_models.ProductHasPromotion.objects.filter(
            promotion_id__in=promotion_ids):
        key = 'webapp_product_detail_{wo:%s}_{pid:%s}' % (webapp_owner_id,
                                                          p.product_id)
        cache_util.delete_cache(key)
Exemplo n.º 5
0
def update_webapp_product_detail_cache(**kwargs):
    """
    更新商品详情缓存
    """
    if hasattr(cache, 'request') and cache.request.user_profile:
        webapp_owner_id = cache.request.user_profile.user_id
        product_ids = None
        cache_args = kwargs.get('cache_args', None)
        if cache_args:
            product_ids = cache_args.get('ids', [])

        if product_ids and len(product_ids) > 0:
            for product_id in product_ids:
                key = 'webapp_product_detail_{wo:%s}_{pid:%s}' % (
                    webapp_owner_id, product_id)
                cache_util.delete_cache(key)
                url = 'http://%s/termite/workbench/jqm/preview/?woid=%s&module=mall&model=product&rid=%s' % \
                    (settings.DOMAIN, webapp_owner_id, product_id)
                if not settings.IS_UNDER_BDD:
                    request = urllib2.Request(url)
                    request.get_method = lambda: 'PURGE'
                    urllib2.urlopen(request)
                # 更新微众商城缓存
                # TODO 更好的设计微众商城
                if webapp_owner_id != 216:
                    key = 'webapp_product_detail_{wo:%s}_{pid:%s}' % (
                        216, product_id)
                    cache_util.delete_cache(key)
            if webapp_owner_id != 216:
                cache_util.delete_cache('webapp_products_categories_{wo:216}')
        else:
            pattern = 'webapp_product_detail_{wo:%s}_*' % webapp_owner_id
            cache_util.delete_pattern(pattern)
Exemplo n.º 6
0
def update_forbidden_coupon_product_ids(**kwargs):
    if hasattr(cache, 'request') and cache.request.user_profile:
        webapp_owner_id = cache.request.user_profile.user_id
        key = 'forbidden_coupon_products_%s' % webapp_owner_id
        cache_util.delete_cache(key)
Exemplo n.º 7
0
def update_webapp_mall_config_cache(**kwargs):
    if hasattr(cache, 'request') and cache.request.user_profile:
        webapp_owner_id = cache.request.user_profile.user_id
        key = 'webapp_mall_config_{wo:%s}' % webapp_owner_id
        cache_util.delete_cache(key)
Exemplo n.º 8
0
def update_webapp_product_cache(**kwargs):
    if hasattr(cache, 'request') and cache.request.user_profile:
        webapp_owner_id = cache.request.user_profile.user_id
        key = 'webapp_products_categories_{wo:%s}' % webapp_owner_id
        cache_util.delete_cache(key)