Example #1
0
def get_common_context(request):
    c = {}
    c['request_url'] = request.path
    c['user'] = request.user
    c['authentication_form'] = AuthenticationForm()
    c['categories'] = Category.objects.filter(parent=None).extra(order_by = ['id'])
    c['brands'] = Brand.objects.all()
    c['colors'] = Color.objects.all()
    c['materials'] = Material.objects.all()
    c['news_left'] = NewsItem.objects.all()[0:3]
    c['user_opt'] = request.user.is_authenticated() and request.user.get_profile().is_opt 
    
    if request.user.is_authenticated():
        c['cart_working'] = Cart
        Cart.update(request.user, SessionCartWorking(request).pop_content())
    else:
        c['cart_working'] = SessionCartWorking(request)
    c['cart_count'], c['cart_sum'] = c['cart_working'].get_goods_count_and_sum(request.user)
    c['cart_content'] = c['cart_working'].get_content(request.user)
    c.update(csrf(request))
    
    if request.method == 'POST' and 'action' in request.POST and request.POST['action'] == 'call_request':
        from call_request.forms import CallRequestForm
        crf = CallRequestForm(request.POST)
        if crf.is_valid():
            crf.save()
            c['call_sent'] = True
        else:
            c['crf'] = crf
    
    return c
Example #2
0
File: views.py Project: kpx13/navaz
def get_common_context(request):
    c = context()
    c["request_url"] = request.path
    c["user"] = request.user
    c["authentication_form"] = AuthenticationForm()
    c["car_models"] = CarModel.objects.all()
    c["colors"] = Color.objects.all()
    c["categories"] = Category.objects.all()
    if request.user.is_authenticated():
        c["cart_working"] = Cart
        Cart.update(request.user, SessionCartWorking(request).pop_content())
    else:
        c["cart_working"] = SessionCartWorking(request)
    c["cart_count"], c["cart_sum"] = c["cart_working"].get_goods_count_and_sum(request.user)
    c.update(csrf(request))
    return c
Example #3
0
File: views.py Project: kpx13/skale
def get_common_context(request):
    c = {}
    c['request_url'] = request.path
    c['user'] = request.user
    c['categories'] = Category.objects.filter(parent=None).extra(order_by = ['id'])
    c['news_left'] = NewsItem.objects.all()[0:3] 
    
    if request.user.is_authenticated():
        c['cart_working'] = Cart
        Cart.update(request.user, SessionCartWorking(request).pop_content())
    else:
        c['cart_working'] = SessionCartWorking(request)
    c['cart_count'], c['cart_sum'] = c['cart_working'].get_goods_count_and_sum(request.user)
    c['cart_content'] = c['cart_working'].get_content(request.user)
    c['slideshow'] = Slider.objects.all()
    c.update(csrf(request))
    
    return c