from copy import deepcopy

from django.shortcuts import render, redirect
from django.http import JsonResponse, HttpResponse
from django.utils.http import url_has_allowed_host_and_scheme
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth import authenticate, login, logout
from rest_framework import viewsets
from rest_framework.authentication import SessionAuthentication, BasicAuthentication
from rest_framework.permissions import DjangoModelPermissions, IsAuthenticated

from django_auto_prefetching import AutoPrefetchViewSetMixin
from . import models
from . import serializers

# def index(request):
#     return HttpResponse("Hello, %s!" % (request.user.username if request.user.is_authenticated else 'World'))

# --------------- FINE PREFISSO TEMPLATE --------------- 
class DestinatarioOfferta_View(viewsets.ModelViewSet):
    # authentication_classes = [BasicAuthentication, SessionAuthentication, TokenAuthentication]
    # permission_classes = [DjangoModelPermissions]

    queryset = models.DestinatarioOfferta.objects.all()
    serializer_class = serializers.DestinatarioOffertaSerializer


class GruppoOfferte_View(viewsets.ModelViewSet):
    # authentication_classes = [BasicAuthentication, SessionAuthentication, TokenAuthentication]
    # permission_classes = [DjangoModelPermissions]

    queryset = models.GruppoOfferte.objects.all()
    serializer_class = serializers.GruppoOfferteSerializer


class Offerta_View(viewsets.ModelViewSet):
    # authentication_classes = [BasicAuthentication, SessionAuthentication, TokenAuthentication]
    # permission_classes = [DjangoModelPermissions]

    queryset = models.Offerta.objects.all()
    serializer_class = serializers.OffertaSerializer


class AgenteOfferta_View(viewsets.ModelViewSet):
    # authentication_classes = [BasicAuthentication, SessionAuthentication, TokenAuthentication]
    # permission_classes = [DjangoModelPermissions]

    queryset = models.AgenteOfferta.objects.all()
    serializer_class = serializers.AgenteOffertaSerializer


class ParteEconomicaOfferta_View(viewsets.ModelViewSet):
    # authentication_classes = [BasicAuthentication, SessionAuthentication, TokenAuthentication]
    # permission_classes = [DjangoModelPermissions]

    queryset = models.ParteEconomicaOfferta.objects.all()
    serializer_class = serializers.ParteEconomicaOffertaSerializer


class TipologiaOfferta_View(viewsets.ModelViewSet):
    # authentication_classes = [BasicAuthentication, SessionAuthentication, TokenAuthentication]
    # permission_classes = [DjangoModelPermissions]

    queryset = models.TipologiaOfferta.objects.all()
    serializer_class = serializers.TipologiaOffertaSerializer


