示例#1
0
def settings(request):
    shop_config = Config.objects.get_current()
    cart = Cart.objects.from_request(request)

    all_categories = Category.objects.by_site()

    try:
        sale = Discount.objects.get_sale()
    except Discount.DoesNotExist:
        sale = None

    ctx = {
        "shop_base": get_satchmo_setting("SHOP_BASE"),
        "shop": shop_config,
        "shop_name": shop_config.store_name,
        "media_url": current_media_url(request),
        "cart_count": cart.numItems,
        "cart": cart,
        "categories": all_categories,
        "is_secure": request_is_secure(request),
        "request": request,
        "login_url": site_settings.LOGIN_URL,
        "logout_url": site_settings.LOGOUT_URL,
        "sale": sale,
    }

    satchmo_context.send(shop_config, context=ctx)

    return ctx
示例#2
0
def settings(request):
    shop_config = Config.objects.get_current()
    cart = Cart.objects.from_request(request)

    all_categories = Category.objects.by_site()

    try:
        sale = Discount.objects.get_sale()
    except Discount.DoesNotExist:
        sale = None

    ctx = {
        'shop_base': get_satchmo_setting('SHOP_BASE'),
        'shop': shop_config,
        'shop_name': shop_config.store_name,
        'media_url': current_media_url(request),
        'cart_count': cart.numItems,
        'cart': cart,
        'categories': all_categories,
        'is_secure': request_is_secure(request),
        'request': request,
        'login_url': site_settings.LOGIN_URL,
        'logout_url': site_settings.LOGOUT_URL,
        'storewide_sale': sale
    }

    satchmo_context.send(shop_config, context=ctx)

    return ctx
示例#3
0
def settings(request):
    shop_config = Config.objects.get_current()
    cart = Cart.objects.from_request(request)

    all_categories = Category.objects.by_site()

    try:
        sale = Discount.objects.get_sale()
    except Discount.DoesNotExist:
        sale = None

    ctx = {
        'shop_base': get_satchmo_setting('SHOP_BASE'),
        'shop' : shop_config,
        'shop_name': shop_config.store_name,
        'media_url': current_media_url(request),
        'cart_count': cart.numItems,
        'cart': cart,
        'categories': all_categories,
        'is_secure' : request_is_secure(request),
        'request' : request,
        'login_url': site_settings.LOGIN_URL,
        'logout_url': site_settings.LOGOUT_URL,
        'storewide_sale': sale
    }

    satchmo_context.send(shop_config, context=ctx)

    return ctx
示例#4
0
def settings(request):
    shop_config = Config.objects.get_current()
    cart = Cart.objects.from_request(request)

    all_categories = Category.objects.by_site()
    
    today = datetime.date.today()
    discs = Discount.objects.filter(automatic=True, 
        active=True, 
        startDate__lte=today, 
        endDate__gt=today).order_by('-percentage')
    if discs.count() > 0:
        sale = discs[0]
    else:
        sale = None

    ctx = {
        'shop_base': get_satchmo_setting('SHOP_BASE'),
        'shop' : shop_config,
        'shop_name': shop_config.store_name,
        'media_url': current_media_url(request),
        'cart_count': cart.numItems,
        'cart': cart,
        'categories': all_categories,
        'is_secure' : request_is_secure(request),
        'request' : request,
        'login_url': site_settings.LOGIN_URL,
        'logout_url': site_settings.LOGOUT_URL,
        'sale': sale
    }
    
    satchmo_context.send(shop_config, context=ctx)
    
    return ctx
示例#5
0
def settings(request):
    # We only insert Satchmo context if we are in the shop subpages to
    # avoid unnecessary db queries
    try:
        url_name = request.resolver_match.url_name
        if not url_name or 'satchmo' not in url_name:
            return {}
    except AttributeError:
        return {}

    shop_config = Config.objects.get_current()
    cart = Cart.objects.from_request(request)

    all_categories = Category.objects.by_site()

    # We don't care about the store-wide sale, commented out to hide extra
    # SQL queries
    #  try:
    #      sale = Discount.objects.get_sale()
    #  except Discount.DoesNotExist:
    #      sale = None
    sale = None

    ctx = {
        'shop_base': get_satchmo_setting('SHOP_BASE'),
        'shop': shop_config,
        'shop_name': shop_config.store_name,
        'media_url': current_media_url(request),
        'STATIC_URL': current_static_url(request),
        'cart_count': cart.numItems,
        'cart': cart,
        'categories': all_categories,
        'is_secure': request_is_secure(request),
        'request': request,
        'login_url': site_settings.LOGIN_URL,
        'logout_url': site_settings.LOGOUT_URL,
        'storewide_sale': sale
    }

    # the signal can by used to dynamically customize context variables
    satchmo_context.send(shop_config, context=ctx)

    return ctx