minor: ruff formatter
All changes are either: - Correcting tabs - Adding/removing line breaks - Adding trailing commas
This commit is contained in:
parent
b2e5dd2ebb
commit
c689ac1e10
91 changed files with 1710 additions and 689 deletions
|
|
@ -5,6 +5,7 @@ Exports:
|
|||
- org_model_query_dependency: org_model: Gets org model from db, if it exists. Uses org_id from query param. Also verifies if the org has been approved.
|
||||
- org_model_body_dependency: org_model: Gets org model from db, if it exists. Uses org_id from request body. Also verifies if the org has been approved.
|
||||
"""
|
||||
|
||||
from typing import Annotated, Optional
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
|
|
@ -25,25 +26,40 @@ def get_org_model(db: Session, request: Request, org_id: int):
|
|||
|
||||
root = "/api/v1"
|
||||
|
||||
pre_approval_endpoints = [f"PATCH{root}/org/status", f"PATCH{root}/org/questionnaire", f"GET{root}/org", f"GET{root}/org/contact", f"PATCH{root}/org/contact"]
|
||||
pre_approval_endpoints = [
|
||||
f"PATCH{root}/org/status",
|
||||
f"PATCH{root}/org/questionnaire",
|
||||
f"GET{root}/org",
|
||||
f"GET{root}/org/contact",
|
||||
f"PATCH{root}/org/contact",
|
||||
]
|
||||
current_request = f"{request.method}{request.url.path}"
|
||||
if current_request not in pre_approval_endpoints and org_model.status != OrgStatus.APPROVED:
|
||||
if (
|
||||
current_request not in pre_approval_endpoints
|
||||
and org_model.status != OrgStatus.APPROVED
|
||||
):
|
||||
raise AwaitingApprovalException(org_id)
|
||||
|
||||
return org_model
|
||||
|
||||
|
||||
def get_org_model_query(db: db_dependency, request: Request, org_id: Annotated[int, Query(gt=0)]) -> type[Org]:
|
||||
def get_org_model_query(
|
||||
db: db_dependency, request: Request, org_id: Annotated[int, Query(gt=0)]
|
||||
) -> type[Org]:
|
||||
return get_org_model(db, request, org_id)
|
||||
|
||||
|
||||
org_model_query_dependency = Annotated[type[Org], Depends(get_org_model_query)]
|
||||
|
||||
|
||||
def get_org_model_body(db: db_dependency, request: Request, request_model: OrgIDMixin) -> type[Org]:
|
||||
def get_org_model_body(
|
||||
db: db_dependency, request: Request, request_model: OrgIDMixin
|
||||
) -> type[Org]:
|
||||
org_id: Optional[int] = getattr(request_model, "organisation_id", None)
|
||||
if org_id is None:
|
||||
raise OrgNotFoundException
|
||||
|
||||
return get_org_model(db, request, org_id)
|
||||
|
||||
|
||||
org_model_body_dependency = Annotated[type[Org], Depends(get_org_model_body)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue