38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
from django_core.mixins import BaseViewSetMixin # type: ignore
|
|
from drf_spectacular.utils import extend_schema
|
|
from rest_framework.permissions import IsAdminUser, AllowAny # type: ignore
|
|
from rest_framework.viewsets import ModelViewSet # type: ignore
|
|
|
|
from core.apps.companies.models import CompanyAccountModel
|
|
from core.apps.companies.serializers.accounts import (
|
|
CreateCompanyAccountSerializer,
|
|
ListCompanyAccountSerializer,
|
|
RetrieveCompanyAccountSerializer,
|
|
UpdateCompanyAccountSerializer,
|
|
DestroyCompanyAccountSerializer,
|
|
)
|
|
|
|
######################################################################
|
|
# Crud
|
|
######################################################################
|
|
@extend_schema(tags=["CompanyAccount"])
|
|
class CompanyAccountCrudViewSet(BaseViewSetMixin, ModelViewSet):
|
|
queryset = CompanyAccountModel.objects.all()
|
|
serializer_class = ListCompanyAccountSerializer
|
|
permission_classes = [AllowAny]
|
|
|
|
action_permission_classes = {
|
|
"list": [IsAdminUser],
|
|
"retrieve": [IsAdminUser],
|
|
"create": [IsAdminUser],
|
|
"update": [IsAdminUser],
|
|
"destroy": [IsAdminUser],
|
|
}
|
|
action_serializer_class = { # type: ignore
|
|
"list": ListCompanyAccountSerializer,
|
|
"retrieve": RetrieveCompanyAccountSerializer,
|
|
"create": CreateCompanyAccountSerializer,
|
|
"update": UpdateCompanyAccountSerializer,
|
|
"destroy": DestroyCompanyAccountSerializer,
|
|
}
|