36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
from django_core.mixins import BaseViewSetMixin
|
|
from drf_spectacular.utils import extend_schema
|
|
from rest_framework.permissions import IsAdminUser, AllowAny
|
|
from rest_framework.viewsets import ModelViewSet
|
|
|
|
from core.apps.companies.models import CompanyAccountModel
|
|
from core.apps.companies.serializers.accounts import (
|
|
CreateCompanyAccountSerializer,
|
|
ListCompanyAccountSerializer,
|
|
RetrieveCompanyAccountSerializer,
|
|
UpdateCompanyAccountSerializer,
|
|
DestroyCompanyAccountSerializer,
|
|
)
|
|
|
|
|
|
@extend_schema(tags=["CompanyAccount"])
|
|
class CompanyAccountView(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 = {
|
|
"list": ListCompanyAccountSerializer,
|
|
"retrieve": RetrieveCompanyAccountSerializer,
|
|
"create": CreateCompanyAccountSerializer,
|
|
"update": UpdateCompanyAccountSerializer,
|
|
"destroy": DestroyCompanyAccountSerializer,
|
|
}
|