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 BMCModelloDiBusiness_View(viewsets.ModelViewSet):
    # authentication_classes = [BasicAuthentication, SessionAuthentication, TokenAuthentication]
    # permission_classes = [DjangoModelPermissions]

    queryset = models.BMCModelloDiBusiness.objects.all()
    serializer_class = serializers.BMCModelloDiBusinessSerializer


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

    queryset = models.BMCPartnerChiave.objects.all()
    serializer_class = serializers.BMCPartnerChiaveSerializer


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

    queryset = models.BMCSegmentiDiClientela.objects.all()
    serializer_class = serializers.BMCSegmentiDiClientelaSerializer


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

    queryset = models.BMCRelazioneConCliente.objects.all()
    serializer_class = serializers.BMCRelazioneConClienteSerializer


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

    queryset = models.BMCAttivitaChiave.objects.all()
    serializer_class = serializers.BMCAttivitaChiaveSerializer


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

    queryset = models.BMCPropostaDiValore.objects.all()
    serializer_class = serializers.BMCPropostaDiValoreSerializer


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

    queryset = models.BMCRisorsaChiave.objects.all()
    serializer_class = serializers.BMCRisorsaChiaveSerializer


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

    queryset = models.BMCFlussoDiRicavi.objects.all()
    serializer_class = serializers.BMCFlussoDiRicaviSerializer


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

    queryset = models.BMCCanaleDiDistribuzione.objects.all()
    serializer_class = serializers.BMCCanaleDiDistribuzioneSerializer
