Server backup 2026-11-07 of uncommitted work in projects/pharma-web-celtic

Snapshot of the working tree on srv1071960 (branch main), taken during
server cleanup. .env files, node_modules, builds, logs and media were excluded.
This commit is contained in:
Shubhankar45
2026-11-07 05:43:12 +00:00
parent b001e2d03c
commit 0d30c58bf0
98 changed files with 1878 additions and 573 deletions
+31 -9
View File
@@ -18,8 +18,19 @@ router = APIRouter(prefix="/chemists", tags=["chemists"])
@router.get("", response_model=list[ChemistRead])
async def list_chemists(
current_user: User = Depends(get_current_user), db: AsyncSession = Depends(get_db)
) -> list[Chemist]:
return await ChemistService(db).list_for(current_user)
) -> list[ChemistRead]:
service = ChemistService(db)
chemists = await service.list_for(current_user)
names = await service.assigned_mr_names([c.id for c in chemists])
return [
ChemistRead.model_validate(c).model_copy(
update={
"assigned_mr_id": names[c.id][0] if c.id in names else None,
"assigned_mr_name": names[c.id][1] if c.id in names else None,
}
)
for c in chemists
]
@router.post("", response_model=ChemistRead, status_code=status.HTTP_201_CREATED)
@@ -29,7 +40,7 @@ async def create_chemist(
current_user: User = Depends(require_role(Role.ADMIN, Role.MR)),
db: AsyncSession = Depends(get_db),
) -> Chemist:
"""An Administrator, or an MR within their own headquarters (AM and GM cannot)."""
"""An Administrator, or an MR within their own headquarters (ABM and AGM cannot)."""
return await ChemistService(db).create(payload, current_user, client_ip(request))
@@ -44,12 +55,23 @@ async def update_chemist(
return await ChemistService(db).update(chemist_id, payload, current_user, client_ip(request))
@router.delete("/{chemist_id}/assign", status_code=status.HTTP_204_NO_CONTENT)
async def unassign_chemist(
chemist_id: uuid.UUID,
request: Request,
current_user: User = Depends(require_role(Role.ADMIN)),
db: AsyncSession = Depends(get_db),
) -> None:
"""Administrator only: leave the chemist with no MR."""
await ChemistService(db).unassign(chemist_id, current_user, client_ip(request))
@router.post("/{chemist_id}/assign", status_code=status.HTTP_201_CREATED)
async def assign_chemist(
chemist_id: uuid.UUID,
payload: AssignToMR,
request: Request,
current_user: User = Depends(require_role(Role.ADMIN, Role.GM, Role.AM)),
current_user: User = Depends(require_role(Role.ADMIN, Role.AGM, Role.ABM)),
db: AsyncSession = Depends(get_db),
):
assignment = await ChemistService(db).assign_to_mr(
@@ -67,8 +89,8 @@ async def assign_chemist(
async def list_chemist_requests(
current_user: User = Depends(get_current_user), db: AsyncSession = Depends(get_db)
) -> list[Chemist]:
"""Chemists an MR added that wait for the Area Manager: an MR sees their own (with any
rejected and why), an Area Manager what waits for them, the administrator and GM all."""
"""Chemists an MR added that wait for the Area Business Manager: an MR sees their own (with any
rejected and why), an Area Business Manager what waits for them, the administrator and AGM all."""
return await ChemistService(db).requests_for(current_user)
@@ -76,10 +98,10 @@ async def list_chemist_requests(
async def approve_chemist(
chemist_id: uuid.UUID,
request: Request,
current_user: User = Depends(require_role(Role.AM, Role.ADMIN)),
current_user: User = Depends(require_role(Role.ABM, Role.ADMIN)),
db: AsyncSession = Depends(get_db),
) -> Chemist:
"""The Area Manager of its headquarters adds it to the list, assigned to the MR who asked."""
"""The Area Business Manager of its headquarters adds it to the list, assigned to the MR who asked."""
return await ChemistService(db).review(chemist_id, True, None, current_user, client_ip(request))
@@ -88,7 +110,7 @@ async def reject_chemist(
chemist_id: uuid.UUID,
payload: RejectMaster,
request: Request,
current_user: User = Depends(require_role(Role.AM, Role.ADMIN)),
current_user: User = Depends(require_role(Role.ABM, Role.ADMIN)),
db: AsyncSession = Depends(get_db),
) -> Chemist:
return await ChemistService(db).review(chemist_id, False, payload.reason, current_user, client_ip(request))