feat: deleted owned org endpoint
All checks were successful
ci / lint_and_test (push) Successful in 14s
All checks were successful
ci / lint_and_test (push) Successful in 14s
This commit is contained in:
parent
3b82025abb
commit
bdba903db1
4 changed files with 50 additions and 1 deletions
|
|
@ -22,6 +22,7 @@ from fastapi import APIRouter, status
|
|||
from fastapi.params import Query
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
|
||||
from src.auth.exceptions import UnauthorizedException
|
||||
from src.contact.schemas import ContactModel
|
||||
from src.exceptions import UnprocessableContentException, ConflictException
|
||||
from src.contact.models import Contact
|
||||
|
|
@ -43,7 +44,7 @@ from src.organisation.dependencies import (
|
|||
org_model_body_dependency,
|
||||
org_model_query_dependency,
|
||||
)
|
||||
from src.organisation.constants import ContactType
|
||||
from src.organisation.constants import ContactType, Status as StatusEnum
|
||||
from src.organisation.models import Organisation as Org
|
||||
from src.organisation.schemas import (
|
||||
OrgPostOrgRequest,
|
||||
|
|
@ -346,6 +347,39 @@ async def delete_organisation_by_id(
|
|||
db.commit()
|
||||
|
||||
|
||||
@router.delete(
|
||||
"/self",
|
||||
summary="Delete organisation from the hub as root user before it has been approved.",
|
||||
status_code=status.HTTP_204_NO_CONTENT,
|
||||
responses={
|
||||
status.HTTP_204_NO_CONTENT: {
|
||||
"description": "Successfully deleted organisation."
|
||||
},
|
||||
status.HTTP_401_UNAUTHORIZED: {
|
||||
"description": "Not authorised. Must be root user."
|
||||
},
|
||||
status.HTTP_422_UNPROCESSABLE_CONTENT: {
|
||||
"description": "Org ID missing or invalid."
|
||||
},
|
||||
},
|
||||
)
|
||||
async def delete_preapproved_organisation_by_id(
|
||||
db: db_dependency,
|
||||
org_model: org_model_root_claim_query_dependency,
|
||||
):
|
||||
"""
|
||||
Removes an organisation from the hub before it has been approved, if user is root.
|
||||
"""
|
||||
org_status = StatusEnum(org_model.status)
|
||||
if not org_status.is_pre_approval:
|
||||
raise UnauthorizedException(
|
||||
message="Organisation is no longer in pre-approval state."
|
||||
)
|
||||
|
||||
db.delete(org_model)
|
||||
db.commit()
|
||||
|
||||
|
||||
@router.patch(
|
||||
"/root_user",
|
||||
summary="Update the root user of the organisation.",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue