예제 #1
0
def get_nintendo_nes_accessories(request):
    user = request.user
    if user.is_authenticated:
        context = build_context(user)
        context['products'] = Product.objects.filter(type_id=3, console_id=2)
    else:
        context = {'products': Product.objects.filter(type_id=3, console_id=2)}
    context['product_type_id'] = 3
    context['header_text'] = str('Nintendo NES ')
    return render(request, 'product/index.html', context=context)
예제 #2
0
def get_videogames_for_console(request, consoleid, header_text):
    user = request.user
    videogames = Product.objects.filter(type_id=2, console_id=consoleid)
    if user.is_authenticated:
        context = build_context(user)
        context['products'] = videogames
    else:
        context = {'products': videogames}
    context['product_type_id'] = 2
    context['header_text'] = header_text
    return render(request, 'product/index.html', context=context)
예제 #3
0
def get_gameboy_advance_consoles(request):
    user = request.user
    consoles = Product.objects.filter(id=5)
    if user.is_authenticated:
        context = build_context(user)
        context['products'] = consoles
    else:
        context = {'products': consoles}
    context['product_type_id'] = 1
    context['header_text'] = str('GameBoy Advance ')
    return render(request, 'product/index.html', context=context)
예제 #4
0
def get_nintendo_64_consoles(request):
    user = request.user
    consoles = Product.objects.filter(id=3)
    if user.is_authenticated:
        context = build_context(user)
        context['products'] = consoles
    else:
        context = {'products': consoles}
    context['product_type_id'] = 1
    context['header_text'] = str('Nintendo 64 ')
    return render(request, 'product/index.html', context=context)
예제 #5
0
def get_videogames_by_genreid(request, genreid, header_text):
    user = request.user
    videogames = Product.objects.filter(videogamehasgenre__genre_id=genreid)
    if user.is_authenticated:
        context = build_context(user)
        context['products'] = videogames
    else:
        context = {'products': videogames}
    context['product_type_id'] = 2
    context['header_text'] = header_text
    context['show_sort'] = True
    return render(request, 'product/index.html', context=context)
예제 #6
0
def get_all_products_sorted(request, orderby, text):
    user = request.user
    consoles = Product.objects.all().order_by(orderby)
    if user.is_authenticated:
        context = build_context(user)
        context['products'] = consoles
    else:
        context = {'products': consoles}
    context['product_type_id'] = 'all'
    context['sort_text'] = 'Sorted by ' + text
    context['show_sort'] = True
    return render(request, 'product/index.html', context=context)
예제 #7
0
def get_videogames_by_playstation(request):
    user = request.user
    playstation1 = Product.objects.filter(type_id=2, console_id=6)
    playstation2 = Product.objects.filter(type_id=2, console_id=7)
    videogames = playstation1.union(playstation2)
    if user.is_authenticated:
        context = build_context(user)
        context['products'] = videogames
    else:
        context = {'products': videogames}
    context['product_type_id'] = 2
    context['header_text'] = str('Playstation ')
    return render(request, 'product/index.html', context=context)
예제 #8
0
def get_videogames_sorted(request, orderby, text):
    user = request.user
    videogames = Product.objects.filter(type_id=2).order_by(orderby)
    if user.is_authenticated:
        context = build_context(user)
        context['products'] = videogames
    else:
        context = {'products': videogames}
    context['product_type_id'] = 2
    context['show_sort'] = True
    context['sort_text'] = 'Sorted by ' + text
    context['header_text'] = 'All '
    return render(request, 'product/index.html', context=context)
예제 #9
0
def get_playstation_accessories(request):
    user = request.user
    playstation1 = Product.objects.filter(type_id=3, console_id=6)
    playstation2 = Product.objects.filter(type_id=3, console_id=7)
    accessories = playstation1.union(playstation2)
    if user.is_authenticated:
        context = build_context(user)
        context['products'] = accessories
    else:
        context = {'products': accessories}
    context['product_type_id'] = 3
    context['header_text'] = str('Playstation ')
    return render(request, 'product/index.html', context=context)
예제 #10
0
def get_nintendo_consoles(request):
    user = request.user
    nintendo_nes = Product.objects.filter(id=2)
    nintendo64 = Product.objects.filter(id=3)
    gameboy_color = Product.objects.filter(id=4)
    gameboy_advance = Product.objects.filter(id=5)
    consoles = nintendo_nes.union(nintendo64, gameboy_color, gameboy_advance)
    if user.is_authenticated:
        context = build_context(user)
        context['products'] = consoles
    else:
        context = {'products': consoles}
    context['product_type_id'] = 1
    context['header_text'] = str('Nintendo ')
    return render(request, 'product/index.html', context=context)
예제 #11
0
def get_accessory_by_id(request, id):
    user = request.user
    if user.is_authenticated:
        user_profile = Profile.objects.get(user=user)
        context = build_context(user)
        try:
            viewed_product = Product.objects.get(id=id)
        except:
            context['message'] = 'Sorry, product not available'
            return render(request, '404.html', context)
        recently_viewed, created = RecentlyViewed.objects.get_or_create(
            profile=user_profile, product=viewed_product)
        recently_viewed.date = datetime.datetime.now()
        recently_viewed.save()
        context['product'] = get_object_or_404(Product, pk=id)
        context['recently_viewed'] = get_recently_viewed(user)
    else:
        context = {'product': get_object_or_404(Product, pk=id)}
    return render(request, 'product/product_details.html', context=context)
예제 #12
0
def cart_details(request):
    user = request.user
    cart_info = build_context(user)
    return render(request, 'order/cart_details.html', context=cart_info)
예제 #13
0
def cart_dropdown(request):
    user = request.user
    cart_info = build_context(user)
    return render(request, 'base.html', context=cart_info)
예제 #14
0
def see_search_history(request):
    user = request.user
    context = build_context(user)
    context['searches'] = Search.objects.filter(profile=user.profile)
    return render(request, 'user/search_history.html', context)