# Path: tests/input/models.py
# class Product(models.Model):
#     pass
# 
# class Category(models.Model):
#     pass


from django.shortcuts import render
from django.http import HttpResponseForbidden, HttpResponseNotFound
from django.core.exceptions import MultipleObjectsReturned
from django.views.generic import TemplateView
from .models import Product, Category
        return render(request, 'product_list.html', context=ctx)
    else:
        return HttpResponseForbidden()


def product_detail_view(request, slug):
    if request.is_authenticated:
        try:
            product = Product.objects.get(slug=slug)
        except MultipleObjectsReturned:
            return HttpResponseNotFound()
        return render(
            request, 'product_detail.html', context={'product': product})
    else:
        return HttpResponseForbidden()


def category_detail_view(request, **kwargs):
    try:
        category = Category.objects.get(pk=kwargs['pk'])
    except Category.DoesNotExist:
        return HttpResponseNotFound()
    return render(
        request, 'category_detail.html', context={'category': category})


class IndexView(TemplateView):

    def get_context_data(self, **kwargs):
        ctx = super(IndexView, self).get_context_data(**kwargs)

# Path: tests/input/models.py
# class Product(models.Model):
#     pass
# 
# class Category(models.Model):
#     pass


# Path: tests/input/func_views_objects_get_without_doesnotexist.py
from django.shortcuts import render
from django.http import HttpResponseForbidden, HttpResponseNotFound
from django.core.exceptions import MultipleObjectsReturned
from django.views.generic import TemplateView
from .models import Product, Category

        return render(request, 'product_list.html', context=ctx)
    else:
        return HttpResponseForbidden()


def product_detail_view(request, slug):
    if request.is_authenticated:
        try:
            product = Product.objects.get(slug=slug)
        except MultipleObjectsReturned:
            return HttpResponseNotFound()
        return render(
            request, 'product_detail.html', context={'product': product})
    else:
        return HttpResponseForbidden()


def category_detail_view(request, **kwargs):
    try:
        category = Category.objects.get(pk=kwargs['pk'])
    except Category.DoesNotExist:
        return HttpResponseNotFound()
    return render(
        request, 'category_detail.html', context={'category': category})


class IndexView(TemplateView):

    def get_context_data(self, **kwargs):
        ctx = super(IndexView, self).get_context_data(**kwargs)

        ctx['cat'] = Category.objects.get(pk=kwargs['cat_id'])