fix - cant delete admin role
This commit is contained in:
@@ -13,6 +13,7 @@ from apps.authorization.api.v1.serializers import (
|
||||
UserRelationSerializer,
|
||||
PageSerializer
|
||||
)
|
||||
from apps.authorization.exception import AdminRoleDeleteException
|
||||
from apps.authorization.models import (
|
||||
Role,
|
||||
Permissions,
|
||||
@@ -41,6 +42,15 @@ class RoleViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet):
|
||||
serializer = self.get_serializer(role, many=True)
|
||||
return self.get_paginated_response(serializer.data)
|
||||
|
||||
def destroy(self, request, pk=None, *args, **kwargs):
|
||||
""" soft delete of role except Admin """
|
||||
|
||||
role = self.get_object()
|
||||
if role.type.key == 'ADM':
|
||||
raise AdminRoleDeleteException()
|
||||
role.soft_delete()
|
||||
return Response(status=status.HTTP_200_OK)
|
||||
|
||||
|
||||
class PageViewSet(SoftDeleteMixin, viewsets.ModelViewSet):
|
||||
""" add website pages to system to set permission on it """
|
||||
|
||||
Reference in New Issue
Block a user