initial commit
This commit is contained in:
35
core/apps/companies/views/accounts.py
Normal file
35
core/apps/companies/views/accounts.py
Normal file
@@ -0,0 +1,35 @@
|
||||
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,
|
||||
}
|
||||
Reference in New Issue
Block a user