diff --git a/src/apps/api/views/profiles.py b/src/apps/api/views/profiles.py index c34fb9482..6492a5efb 100644 --- a/src/apps/api/views/profiles.py +++ b/src/apps/api/views/profiles.py @@ -229,3 +229,25 @@ def validate_invite(self, request): mem_ser = MembershipSerializer(membership) return Response(mem_ser.data, status=status.HTTP_200_OK) + + @action(detail=True, methods=['delete']) + def delete_organization(self, request, pk=None): + try: + org = Organization.objects.get(id=pk) + member = org.membership_set.get(user=request.user) + if member.group == Membership.OWNER: + org.delete() + return Response({ + "success": True, + "message": "Organization deleted!" + }) + else: + return Response({ + "success": False, + "message": "You do not have delete rights!" + }) + except Exception as e: + return Response({ + "success": False, + "message": f"{e}" + }) diff --git a/src/static/js/ours/client.js b/src/static/js/ours/client.js index 3c4a6ae05..f3e1a21dc 100644 --- a/src/static/js/ours/client.js +++ b/src/static/js/ours/client.js @@ -276,6 +276,9 @@ CODALAB.api = { delete_organization_member: (id, data) => { return CODALAB.api.request('DELETE', `${URLS.API}organizations/${id}/delete_member/`, data) }, + delete_organization: (id) => { + return CODALAB.api.request('DELETE', `${URLS.API}organizations/${id}/delete_organization/`) + }, /*--------------------------------------------------------------------- Participants ---------------------------------------------------------------------*/ diff --git a/src/templates/profiles/organization_detail.html b/src/templates/profiles/organization_detail.html index 8b99319a1..386403a22 100644 --- a/src/templates/profiles/organization_detail.html +++ b/src/templates/profiles/organization_detail.html @@ -6,6 +6,18 @@ {% if is_editor %}
{% endif %}{{ organization.description | linebreaks }}