Beispiel #1
0
def laptops(request):
    # ad = Ads.objects.order_by('?').filter(expired='False',ad_type="Banner")[:2]
    # prod_ad = Ads.objects.order_by('?').filter(expired='False',ad_type="Products")[:1]
    # print(screen_width)
    # ad = Ads.objects.order_by('?')[:1]
    # seen_by(request,ad)
    # landlord(request,ad)
    # seen_by(request,prod_ad)
    # landlord(request,prod_ad)
    user_count(request)
    url = request.build_absolute_uri()
    whichPage(request, 'laptopsP', url)
    t1 = time.time()
    share_string = 'Compare Laptops - Latest Laptops by Price'
    orginal_sentence = []
    corrected_sentence = []
    confirmed = None
    all_products = Products.objects.order_by('?').filter(genre='laptops')
    # if corrected_sentence != orginal_sentence:
    # 	corrected_sentence = ' '.join(corrected_sentence)
    # 	orginal_sentence = ' '.join(orginal_sentence)
    # 	confirmed = 'Showing result of {0} instead of {1}'.format(corrected_sentence,orginal_sentence)
    page_request_var = 'page'
    paginator = Paginator(all_products, 20)
    page = request.GET.get(page_request_var)
    try:
        queryset = paginator.page(page)
    except PageNotAnInteger:
        queryset = paginator.page(1)
    except EmptyPage:
        if request.is_ajax():
            # If the request is AJAX and the page is out of range return an empty page
            return HttpResponse('')
    if request.is_ajax():
        return render(request, 'results_ajax.html', {'products': queryset})
    context = {
        'products': queryset,
        'confirmed': confirmed,
        'all_product': all_products,
        'share_string': share_string,
        'share_stringe': share_stringe,
        'page': 'laptop_page'
    }
    # print(all_products.count())
    t2 = time.time()
    query_time = t2 - t1
    query_time = '{:.6f}'.format(query_time)
    context['query_time'] = query_time
    return render(request, 'results_page.html', context)
Beispiel #2
0
def women_watch(request):
    # ad = Ads.objects.order_by('?').filter(expired='False',ad_type="Banner")[:2]
    # prod_ad = Ads.objects.order_by('?').filter(expired='False',ad_type="Products")[:1]
    # print(screen_width)
    # ad = Ads.objects.order_by('?')[:1]
    # seen_by(request,ad)
    # landlord(request,ad)
    # seen_by(request,prod_ad)
    # landlord(request,prod_ad)
    user_count(request)
    url = request.build_absolute_uri()
    t1 = time.time()
    whichPage(request, 'wemen_watchP', url)
    share_string = 'Compare Beautiful Women Watches - Latest Beautiful Women Watches by Price & Shop'
    confirmed = None
    all_products = Products.objects.order_by('?').filter(genre='women-watches')
    page_request_var = 'page'
    paginator = Paginator(all_products, 20)
    page = request.GET.get(page_request_var)
    try:
        queryset = paginator.page(page)
    except PageNotAnInteger:
        queryset = paginator.page(1)
    except EmptyPage:
        if request.is_ajax():
            # If the request is AJAX and the page is out of range return an empty page
            return HttpResponse('')
    if request.is_ajax():
        return render(request, 'results_ajax.html', {'products': queryset})
    context = {
        'products': queryset,
        'confirmed': confirmed,
        'all_product': all_products,
        'share_string': share_string,
        'share_stringe': share_stringe,
        'page': 'women_page'
    }
    # print(all_products.count())
    t2 = time.time()
    query_time = t2 - t1
    query_time = '{:.6f}'.format(query_time)
    context['query_time'] = query_time
    return render(request, 'results_page.html', context)
Beispiel #3
0
def home_page(request):
    share_string = quote_plus(
        'compare price from different stores at quickfinda.com #popular')
    url = request.build_absolute_uri()
    whichPage(request, 'home_page', url)
    user = get_client_ip(request)
    userTheme = ''
    if UserTheme.objects.filter(user=user).exists():
        user_theme = UserTheme.objects.get(user=user)
    user_count(request)
    # ipo = get_client_ip(request)
    # if UserTheme.objects.filter(user=ipo).exists():
    # 	bool_boy = True

    # ad = Ads.objects.order_by('?').filter(expired='False',ad_type="Banner")[:1]
    # seen_by(request,ad)
    # landlord(request,ad)
    context = {'share_string': share_string, 'url': url, 'page': 'front_page'}
    return render(request, 'search_page.html', context)