# 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
"""
Check calling objects.get inside try-except
"""
from __future__ import (absolute_import, division,
                        print_function, unicode_literals)



def product_list_view(request, cat_id):
    if request.is_authenticated():
        ctx = {'products': Product.objects.all(),
               'cat_id': cat_id}
        return render(request, 'product_list.html', context=ctx)
    else:
        return HttpResponseForbidden()


def product_detail_view(request, slug):
    if request.is_authenticated:
        try:

# 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

"""
Check calling objects.get inside try-except
"""
from __future__ import (absolute_import, division,
                        print_function, unicode_literals)



def product_list_view(request, cat_id):
    if request.is_authenticated():
        ctx = {'products': Product.objects.all(),
               'cat_id': cat_id}
        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)