Esempio n. 1
0
def store(request):
    urll = request.build_absolute_uri()
    share_string = 'Shop from all shops using our Price Comparison engine'
    whichPage(request, 'shop_index', urll)
    # ad = Ads.objects.order_by('?').filter(expired='False',ad_type="Banner")[:2]
    # seen_by(request,ad)
    # landlord(request,ad)
    return render(request, 'shop/index.html', {
        'page': 'shop',
        'share_string': share_string
    })
Esempio n. 2
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)
Esempio n. 3
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)
Esempio n. 4
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)
Esempio n. 5
0
def search_bite(query):
    #experimental_search(request, query)
    all_products = Products.objects.order_by('?')
    whichPage(request, 'search', request.build_absolute_uri())
    if 'iphone' in str(query.lower()) or 'ipad' in str(query.lower()):
        # # print(query)
        # print(list(query))
        query = query.lower()
        quey = query.split()

        for stop_w in STOP_WORDS:
            if stop_w in quey:
                quey.remove(stop_w)

        if len(quey) >= 3:
            if 'plus' in quey and len(quey) <= 3:
                q = ' '.join(quey)

                all_products = all_products.filter(
                    Q(name__icontains=q) | Q(name__iexact=q)).distinct()
            else:
                for q in quey:
                    all_products = all_products.filter(
                        Q(name__icontains=q)).distinct()

            add_query(query,
                      'search page',
                      all_products[:10],
                      nbool=True,
                      correct=query,
                      request=request)
        else:
            # query = correction(query)
            query = query.strip()
            query = query.split()
            for stop_w in STOP_WORDS:
                if stop_w in query:
                    query.remove(stop_w)

            query = ' '.join(query)
            all_products = all_products.filter(
                Q(name__icontains=query) | Q(name__iexact=query)).distinct()
            print(query)
            if len(all_products) == 0:
                add_query(query,
                          'search page',
                          all_products[:10],
                          nbool=False,
                          correct=query,
                          request=request)
            else:
                print(query)
                add_query(query,
                          'search page',
                          all_products[:10],
                          nbool=True,
                          correct=query,
                          request=request)
    else:
        query = query.split()
        new = []
        for stop_w in STOP_WORDS:
            if stop_w in query:
                query.remove(stop_w)
        for q in query:
            # q = correction(q)

            # print(q)
            new.append(q)
            # Put them all together

            all_products = all_products.filter(
                Q(name__icontains=q) | Q(name__iexact=q)).distinct()

            query = ''.join(query)
        made = ' '.join(new)
        if len(all_products) == 0:
            add_query(made,
                      'search page',
                      all_products[:10],
                      nbool=False,
                      correct=made,
                      request=request)
        else:
            add_query(made,
                      'search page',
                      all_products[:10],
                      nbool=True,
                      correct=made,
                      request=request)

    return all_products
Esempio n. 6
0
def store_details(request, word):
    urll = request.build_absolute_uri()
    # ad = Ads.objects.order_by('?').filter(expired='False',ad_type="Banner")[:2]
    # seen_by(request,ad)
    # landlord(request,ad)
    share_string = '{} - Quickfinda Shopping Nigeria'.format(word.capitalize())
    pink_lips = request.GET.get('q')
    if pink_lips:
        whichPage(request, '%s-%s' % (word, pink_lips), urll)
    else:
        whichPage(request, word, urll)
    t1 = time.time()
    orginal_sentence = []
    corrected_sentence = []
    confirmed = None
    all_products = Products.objects.order_by('?').filter(shop=word)
    product_counter = all_products.count()
    query = request.GET.get('q')
    if query:
        all_products = Products.objects.all().filter(shop=word)
        if 'iphone' in str(query.lower()) or 'ipad' in str(query.lower()):
            quey = query.split()
            if len(quey) >= 3:
                for q in quey:
                    all_products = all_products.filter(
                        Q(name__icontains=q) | Q(name__iexact=q)).distinct()
            else:
                query = query.strip()
                all_products = all_products.filter(
                    Q(name__icontains=query)
                    | Q(name__iexact=query)).distinct()
        else:
            query = query.split()
            for q in query:
                all_products = all_products.filter(
                    Q(name__icontains=q) | Q(name__iexact=q)).distinct()
        # 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)
        query = ' '.join(query)
    # page_request_var = 'page'
    com = ''
    page_request_var = 'page'
    if page_request_var and query:
        com = 'Nothing'
    paginator = Paginator(all_products, 40)
    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, 'shop/results_ajax.html',
                      {'products': queryset})
    context = {
        'products': queryset,
        'query': query,
        'confirmed': confirmed,
        'all_product': all_products,
        'share_string': share_string,
        'shop': word,
        'mack': 'mack',
        'com': com,
        'page': word + '_shop' + '_index'
    }
    # 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, 'shop/results_page.html', context)
Esempio n. 7
0
def real_trend(request, word):
    share_string = 'Compare Trending Products - Latest Trending Products by Price & Shop'
    t1 = time.time()
    url = request.build_absolute_uri()
    whichPage(request, 'Trending', url)
    orginal_sentence = []
    corrected_sentence = []
    confirmed = None
    query = request.GET.get('q')
    if word != 'index':
        all_products = Products.objects.order_by('-num_of_clicks').filter(
            genre=word)
    else:
        all_products = Products.objects.order_by('-num_of_clicks')
    if query:
        whichPage(request, 'search Trending', request.build_absolute_uri())
        if 'iphone' in str(query.lower()) or 'ipad' in str(query.lower()):
            # # print(query)
            # print(list(query))
            query = query.lower()
            quey = query.split()
            if len(quey) >= 3:
                if 'plus' in quey and len(quey) <= 3:
                    q = ' '.join(quey)
                    all_products = all_products.filter(
                        Q(name__icontains=q) | Q(name__iexact=q)).distinct()
                else:
                    for q in quey:
                        all_products = all_products.filter(
                            Q(name__icontains=q)).distinct()
                add_query(query, 'search page', all_products[:10], nbool=True)
            else:
                # query = correction(query)
                query = query.strip()
                all_products = all_products.filter(
                    Q(name__icontains=query)
                    | Q(name__iexact=query)).distinct()
                if len(all_products) == 0:
                    add_query(query,
                              'search page',
                              all_products[:10],
                              nbool=False)
                else:
                    add_query(query,
                              'search page',
                              all_products[:10],
                              nbool=True)
        else:
            query = query.split()
            for q in query:
                all_products = all_products.filter(
                    Q(name__icontains=q) | Q(name__iexact=q)).distinct()
            query = ' '.join(query)
            if len(all_products) == 0:
                add_query(query, 'search page', all_products[:10], nbool=False)
            else:
                add_query(query, 'search page', all_products[:10], nbool=True)
    # 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, 40)
    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,
        'query': query,
        'confirmed': confirmed,
        'all_product': all_products,
        'share_string': share_string,
        'page': 'trending_' + word
    }
    # print(all_products.count())
    t2 = time.time()
    query_time = t2 - t1
    query_time = '{:.3f}'.format(query_time)
    context['query_time'] = query_time
    return render(request, 'result_trend_page.html', context)