@@ -402,6 +402,7 @@ def post(self, request, *args, **kwargs) -> JsonResponse: # type: ignore[no-unt
402402
403403
404404@method_decorator (is_platform_admin (), name = "post" )
405+ @method_decorator (is_platform_admin (), name = "delete" )
405406class SingleOrganizationView (View ):
406407 def post (self , request , * args , ** kwargs ) -> JsonResponse : # type: ignore[no-untyped-def]
407408 try :
@@ -431,6 +432,20 @@ def post(self, request, *args, **kwargs) -> JsonResponse: # type: ignore[no-unt
431432 except IntegrityError as e :
432433 return JsonResponse ({"error" : str (e )}, status = 409 )
433434
435+ def delete (self , request , * args , ** kwargs ): # type: ignore[no-untyped-def]
436+ try :
437+ organization = Organization .objects .get (id = kwargs ["organization_id" ])
438+ organization .delete ()
439+ return JsonResponse (
440+ {"message" : "Organization deleted successfully" }, status = 200
441+ )
442+ except Organization .DoesNotExist :
443+ return JsonResponse ({"error" : "Organization not found" }, status = 404 )
444+ except ValidationError as e :
445+ return JsonResponse ({"error" : e .json ()}, status = 400 )
446+ except IntegrityError as e :
447+ return JsonResponse ({"error" : str (e )}, status = 409 )
448+
434449
435450@method_decorator (accessible_for (roles = {"admin" , "editor" }), name = "post" )
436451class FileView (View ):
0 commit comments