import logging
import os

from django.conf import settings
from rest_framework import viewsets, status
from rest_framework.mixins import ListModelMixin, DestroyModelMixin, CreateModelMixin
from rest_framework.response import Response

from core.mixins import ApiPermissionCheckMixin
from inputs.models import LogInput
from inputs.serializers import InputSerializer
from inputs.services.delete_input import delete_input
from perms.models import Perm

_log = logging.getLogger()


class InputViewSet(ApiPermissionCheckMixin,
                   viewsets.ModelViewSet):
    serializer_class = InputSerializer
    console_permissions = _classes = {'list': [Perm.can_view_input_list], 'create': [Perm.can_add_input],
                                      'retrieve': [Perm.can_view_input_list], 'update': [Perm.can_edit_input],
                                      'partial_update': [Perm.can_edit_input], 'destroy': [Perm.can_delete_input]}
    queryset = LogInput.objects.all()

    def destroy(self, request, *args, **kwargs):
        return delete_input(self.kwargs)

    class Meta:
        model = LogInput
