Ejemplo n.º 1
0
def contacts (request):
    c = {}
    c.update(csrf(request))
    
    mc = get_base_context(request)

    return render_to_response('contacts.html', mc,context_instance=RequestContext(request))
Ejemplo n.º 2
0
def order_state (request):
    c = {}
    c.update(csrf(request))
    user1 = request.session['user']; 
    print user1.is_staff, user1.login
    if (user1.is_staff == 1):
        try:
            print "Admin"
            baskets = Basket.objects.filter(btype='R')
        except baskets.DoesNotExist:
            return HttpResponse("Error")
    else:
        try:
            print "User"
            baskets = Basket.objects.filter(user=user1)
            print 
        except baskets.DoesNotExist:
            "Bad"
            return HttpResponse("Error")
    
    mc = get_base_context(request)
    
    c = RequestContext(request, {"baskets":  baskets})
    c.dicts += mc.dicts

    return render_to_response('basket/order_state.html', c, context_instance=RequestContext(request))
Ejemplo n.º 3
0
def get_ready (request):
    
    basket = request.session['basket']
    basket.user = request.session['user']
    basket.adding_time = datetime.datetime.now()
    basket.address = request.POST['address']
    basket.tel = request.POST['tel']
    basket.comment = request.POST['comment']
    basket.btype = u'R'
    
    basket.save()
    
    for o in basket.orders:
        o.basket = basket
        o.product.quantity = int(o.product.quantity) - int(o.quantity)
        o.product.save()
        o.save()
    
    request.session['basket'] = None
    
    t = get_template('basket/ready.html')
    if "user" in request.session:
        c = RequestContext(request, {'order_id':basket.id, 'user':request.session['user']})
    else:
        c = RequestContext(request, {'order_id':basket.id})
    
    mc = get_base_context(request)
    c.dicts += mc.dicts
    return HttpResponse(t.render(c))
Ejemplo n.º 4
0
def delivery (request):
    c = {}
    c.update(csrf(request))
    
    mc = get_base_context(request)

    return render_to_response('delivery_terms.html', mc,context_instance=RequestContext(request))   
Ejemplo n.º 5
0
def get_model_frame(request, gr_id, tp_id, pr_id):    
    pr = Product.objects.all().get(id=pr_id)
    t = get_template('products/product_model_frame.html')
    c = RequestContext(request, {'product':pr})
    
    mc = get_base_context(request)
    c.dicts += mc.dicts
    return HttpResponse(t.render(c))
Ejemplo n.º 6
0
def add_news(request):
    if "user" in request.session:
        c = RequestContext(request, {'user':request.session['user']})
    else:
        c = RequestContext(request, {})
    
    mc = get_base_context(request)
    c.dicts += mc.dicts
    return render_to_response('news/add_news.html', {}, c)
Ejemplo n.º 7
0
def index (request):
    c = {}
    c.update(csrf(request))
    #### creating admin and courier ####
    create_admin()
    create_courier()
    
    mc = get_base_context(request)
    
    return render_to_response('index.html', mc ,context_instance=RequestContext(request))
Ejemplo n.º 8
0
def show_news(request):
    news = News.objects.order_by("-id")
    if "user" in request.session:
        c = RequestContext(request, {'user':request.session['user']})
    else:
        c = RequestContext(request, {})
    
    mc = get_base_context(request)
    c.dicts += mc.dicts
    return render_to_response('news/show_news.html', {'news': news}, c)
Ejemplo n.º 9
0
def get_add_group (request):
    
    t = get_template('products/group_add.html')
    if "user" in request.session:
        c = RequestContext(request, {'user':request.session['user'] })
    else:
        c = RequestContext(request, { })
    
    mc = get_base_context(request)
    c.dicts += mc.dicts
    return HttpResponse(t.render(c))
Ejemplo n.º 10
0
def get_all_groups (request):    
    groups = Product_group.objects.all()
    t = get_template('products/groups_list.html')
    if "user" in request.session:
        c = RequestContext(request, {'prod_groups':groups, 'user':request.session['user']})
    else:
        c = RequestContext(request, {'prod_groups':groups})
    
    mc = get_base_context(request)
    c.dicts += mc.dicts
    return HttpResponse(t.render(c))
Ejemplo n.º 11
0
def get_order (request):
    
    t = get_template('basket/order.html')
    if "user" in request.session:
        c = RequestContext(request, {'user':request.session['user']})
    else:
        c = RequestContext(request, { })
    
    mc = get_base_context(request)
    c.dicts += mc.dicts
    return HttpResponse(t.render(c))
Ejemplo n.º 12
0
def get_quest_list (request):
    
    questions = Question.objects.all()
    t = get_template('questions/quest_list.html')
    if "user" in request.session:
        c = RequestContext(request, { 'questions':questions, 'user':request.session['user'] })
    else:
        c = RequestContext(request, { 'questions':questions })
    
    mc = get_base_context(request)
    c.dicts += mc.dicts
    return HttpResponse(t.render(c))
Ejemplo n.º 13
0
def get_add_answer (request, q_id):
    
    question = Question.objects.all().get(id=q_id)
    t = get_template('questions/answer.html')
    if "user" in request.session:
        c = RequestContext(request, { 'quest':question, 'user':request.session['user'] })
    else:    
        c = RequestContext(request, { 'quest':question })
    
    mc = get_base_context(request)
    c.dicts += mc.dicts
    return HttpResponse(t.render(c))
Ejemplo n.º 14
0
def get_prod_group (request, gr_id):    
    gr = Product_group.objects.all().get(id=gr_id)
    types = Product_type.objects.all().filter(group=gr)
    t = get_template('products/types_list.html')
    if "user" in request.session:
        c = RequestContext(request, {'group':gr, 'prod_types':types, 'user':request.session['user']})
    else:
        c = RequestContext(request, {'group':gr, 'prod_types':types})
    
    mc = get_base_context(request)
    c.dicts += mc.dicts
    return HttpResponse(t.render(c))
Ejemplo n.º 15
0
def get_add_prod (request, tp_id):
    tp = Product_type.objects.all().get(id=tp_id)
    gr = tp.group
    t = get_template('products/product_add.html')
    if "user" in request.session:
        c = RequestContext(request, {'group':gr, 'type':tp, 'user':request.session['user']})
    else:
        c = RequestContext(request, {'group':gr, 'type':tp})
    
    mc = get_base_context(request)
    c.dicts += mc.dicts
    return HttpResponse(t.render(c))
Ejemplo n.º 16
0
def esubmit_company(request):
    c = RequestContext(request, {'user' : request.user})   
    p = Company.objects.filter(user = request.user)[0]
    p.name = request.POST.get('name') 
    p.tel = request.POST.get('tel')
    p.city = request.POST.get('city')
    p.address = request.POST.get('address')
    p.post = request.POST.get('post')
    p.description = request.POST.get('description')
    p.save()
    mc = get_base_context(request)
    c.dicts += mc.dicts
    return HttpResponseRedirect('/')
Ejemplo n.º 17
0
def get_add_char (request, pr_id):    
    t = get_template('products/charac_add.html')
    pr = Product.objects.all().get(id=pr_id)
    price = get_last_price(pr_id).value
    charac = Characteristic.objects.all().filter(product=pr_id)
    if "user" in request.session:
        c = RequestContext(request, {'product':pr, 'characs':charac, 'price' : str(price), 'user':request.session['user']})
    else:        
        c = RequestContext(request, {'product':pr, 'characs':charac, 'price' : str(price)})
    
    mc = get_base_context(request)
    c.dicts += mc.dicts
    return HttpResponse(t.render(c))
Ejemplo n.º 18
0
def wholesale(request):
    docs = DocumentFile.objects.all().order_by("-id")
    for doc in docs:
        doc.doc_file_name = doc.doc_file.__unicode__().split('/')[-1]
    c = RequestContext(request, {'user':request.user})
    mc = get_base_context(request)
    c.dicts += mc.dicts
    
    if not request.user.is_authenticated():
        return HttpResponseRedirect('/news/')
    if request.user.is_staff or len(Company.objects.filter(user=request.user))!=0:
        return render_to_response('wholesalers/wholesale.html', {'docs': docs}, c)
    else:
        return HttpResponseRedirect('/add_company/')
Ejemplo n.º 19
0
def get_prod_type (request, gr_id, tp_id):    
    gr = Product_group.objects.all().get(id=gr_id)
    tp = Product_type.objects.all().get(id=tp_id)
    products = Product.objects.all().filter(prod_type=tp)
    for product in products:
        product.price = get_last_price(product.id)
    t = get_template('products/products_list.html')
    if "user" in request.session:
        c = RequestContext(request, {'group':gr, 'type':tp, 'products':products, 'user':request.session['user']})
    else:
        c = RequestContext(request, {'group':gr, 'type':tp, 'products':products})
    
    mc = get_base_context(request)
    c.dicts += mc.dicts
    return HttpResponse(t.render(c))
Ejemplo n.º 20
0
def get_model(request, gr_id, tp_id, pr_id):    
    pr = Product.objects.all().get(id=pr_id)
    gr = Product_group.objects.all().get(id=gr_id)
    tp = Product_type.objects.all().get(id=tp_id)
    price = get_last_price(pr_id)
    characs = Characteristic.objects.all().filter(product=pr)
    t = get_template('products/product_model.html')
    
    if "user" in request.session:
        c = RequestContext(request, {'group':gr, 'type':tp, 'product':pr, 'characs':characs, 'price':price, 'user':request.session['user']})
    else:
        c = RequestContext(request, {'group':gr, 'type':tp, 'product':pr, 'characs':characs, 'price':price})
    
    mc = get_base_context(request)
    c.dicts += mc.dicts
    return HttpResponse(t.render(c))
Ejemplo n.º 21
0
def edit_company(request):
    c = RequestContext(request, {'user' : request.user})
    mc = get_base_context(request)
    c.dicts += mc.dicts
    com = Company.objects.filter(user = request.user)[0]   
    return render_to_response('wholesalers/edit_company.html', {'n': com.name, 't': com.tel, 'c':com.city, 'a':com.address, 'p': com.post, 'd' : com.description})
Ejemplo n.º 22
0
def add_doc(request):
    c = RequestContext(request, {'user' : request.user})
    mc = get_base_context(request)
    c.dicts += mc.dicts
    return render_to_response('wholesalers/add_doc.html', {}, c)