feat: blocked orgs cannot access any endpoints
This commit is contained in:
parent
37a3972d04
commit
c94c26f2a6
2 changed files with 9 additions and 0 deletions
|
|
@ -37,6 +37,10 @@ class Status(StrEnum):
|
||||||
def is_pre_submission(self):
|
def is_pre_submission(self):
|
||||||
return self in (self.PARTIAL, self.REMEDIATION)
|
return self in (self.PARTIAL, self.REMEDIATION)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_blocked(self):
|
||||||
|
return self in (self.REMOVED, self.REJECTED)
|
||||||
|
|
||||||
|
|
||||||
class ContactType(StrEnum):
|
class ContactType(StrEnum):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ from sqlalchemy.orm import Session
|
||||||
from fastapi import Depends, Query, Request
|
from fastapi import Depends, Query, Request
|
||||||
|
|
||||||
from src.database import db_dependency
|
from src.database import db_dependency
|
||||||
|
from src.exceptions import ForbiddenException
|
||||||
|
|
||||||
from src.organisation.schemas import OrgIDMixin
|
from src.organisation.schemas import OrgIDMixin
|
||||||
from src.organisation.models import Organisation as Org
|
from src.organisation.models import Organisation as Org
|
||||||
|
|
@ -24,6 +25,10 @@ def get_org_model(db: Session, request: Request, org_id: int):
|
||||||
if org_model is None:
|
if org_model is None:
|
||||||
raise OrgNotFoundException(org_id)
|
raise OrgNotFoundException(org_id)
|
||||||
|
|
||||||
|
org_status = OrgStatus(org_model.status)
|
||||||
|
if org_status.is_blocked:
|
||||||
|
raise ForbiddenException("This organisation cannot perform this action.")
|
||||||
|
|
||||||
root = "/api/v1"
|
root = "/api/v1"
|
||||||
|
|
||||||
pre_approval_endpoints = [
|
pre_approval_endpoints = [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue