remove bank account when remove org
This commit is contained in:
@@ -231,7 +231,7 @@ class OrganizationTypeViewSet(BaseViewSet, SoftDeleteMixin, ModelViewSet):
|
||||
return self.get_paginated_response(serializer.data)
|
||||
|
||||
|
||||
class OrganizationViewSet(BaseViewSet, SoftDeleteMixin, ModelViewSet, DynamicSearchMixin):
|
||||
class OrganizationViewSet(BaseViewSet, ModelViewSet, DynamicSearchMixin):
|
||||
""" Crud operations for organization model """ #
|
||||
queryset = Organization.objects.all()
|
||||
serializer_class = OrganizationSerializer
|
||||
@@ -384,6 +384,19 @@ class OrganizationViewSet(BaseViewSet, SoftDeleteMixin, ModelViewSet, DynamicSea
|
||||
serializer = self.serializer_class(page, many=True)
|
||||
return self.get_paginated_response(serializer.data)
|
||||
|
||||
@transaction.atomic
|
||||
def destroy(self, request, pk=None, *args, **kwargs):
|
||||
""" remove organization with bank accounts """
|
||||
org = self.get_object()
|
||||
|
||||
org.bank_information.all().update(trash=True)
|
||||
org.soft_delete()
|
||||
|
||||
return Response(
|
||||
{"detail": "رکورد با موفقیت حذف شد (Soft Delete)."}, # noqa
|
||||
status=status.HTTP_204_NO_CONTENT
|
||||
)
|
||||
|
||||
|
||||
class BankAccountViewSet(SoftDeleteMixin, ModelViewSet):
|
||||
""" Crud operations for bank account model """ #
|
||||
|
||||
Reference in New Issue
Block a user