def show_index(request): context = get_context(request) context['carousel'] = get_goods_for_carousel() context['new_items'] = get_goods_for_new() context['sale_items'] = get_goods_for_sale() context['hot_items'] = get_goods_for_hot() return render(request, 'baseapp/index.html', context)
def show_item(request, slug): good = find_good_by_slug(slug=slug) if not good: return redirect(request.META['HTTP_REFERER']) context = get_context(request) parent = good.category childs = get_childs(parent=parent) context['parent'] = parent context['childs'] = childs context['good'] = good return render(request, 'catalogapp/item.html', context)
def send_contact_form(request): context = get_context(request) if request.method == 'POST': contactForm = ContactForm(request.POST) if contactForm.is_valid(): name = contactForm.cleaned_data['contactName'] phone = contactForm.cleaned_data['contactPhone'] message = contactForm.cleaned_data['contactMessage'] send_mail(name, phone, message) return render(request, 'baseapp/contact_form_success.html', context) else: return render(request, 'baseapp/contact_form_error.html', context)
def render_list(request, goods, parent, addon=""): goods_count = 15 childs = get_childs(parent=parent) page_number = request.GET.get('page', 1) paginator = Paginator(goods, goods_count) page = paginator.get_page(page_number) is_paginated = page.has_other_pages() context = get_context(request, parent) context['parent'] = parent context['childs'] = childs context['goods_count'] = len(goods) context['page'] = page context['is_paginated'] = is_paginated context['addon'] = addon return render(request, 'catalogapp/list.html', context)
def show_news(request): context = get_context(request) return render(request, 'baseapp/news.html', context)
def show_brands(request): context = get_context(request) return render(request, 'baseapp/brands.html', context)
def show_map(request): context = get_context(request) return render(request, 'baseapp/map.html', context)
def show_agreement(request): context = get_context(request) return render(request, 'baseapp/agreement.html', context)
def show_delivery(request): context = get_context(request) return render(request, 'baseapp/delivery.html', context)
def show_contacts(request): context = get_context(request) return render(request, 'baseapp/contacts.html', context)
def show_about(request): context = get_context(request) return render(request, 'baseapp/about.html', context)
def show_wishlist(request): # if request.user.is_authenticated: return render(request, 'wishlistapp/wishlist.html', get_context(request))
def order_success(request, id): context = get_context(request) context['order'] = get_order(id) return render(request, 'orderapp/order_success.html', context)
def show_order(request, id): context = get_context(request) context['order'] = get_order(id) return render(request, 'orderapp/order.html', context)
def show_orders(request): context = get_context(request) if request.user.is_authenticated: context['orders'] = get_orders(context['buyer']) return render(request, 'orderapp/orders.html', context)