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:
@@ -1,11 +1,11 @@
|
||||
"""Approval of the doctors and chemists an MR adds.
|
||||
"""Approval of the doctors, chemists and stockists an MR adds.
|
||||
|
||||
MR adds one --> PENDING --approve(AM)--> APPROVED (listed, and visitable by that MR)
|
||||
--reject(AM)---> REJECTED (the MR sees why; adding it again re-sends it)
|
||||
MR adds one --> PENDING --approve(ABM)--> APPROVED (listed, and visitable by that MR)
|
||||
--reject(ABM)---> REJECTED (the MR sees why; adding it again re-sends it)
|
||||
|
||||
Only APPROVED masters are listed or may be visited. The administrator's own additions are
|
||||
APPROVED at once. The reviewer is the Area Manager of the master's headquarters (or the
|
||||
administrator); the General Manager may look but not act.
|
||||
APPROVED at once. The reviewer is the Area Business Manager of the master's headquarters (or the
|
||||
administrator); the Assistant General Manager may look but not act.
|
||||
"""
|
||||
|
||||
import uuid
|
||||
@@ -34,14 +34,22 @@ async def rejected_twin(db: AsyncSession, model: Any, match: dict[str, Any]) ->
|
||||
|
||||
|
||||
async def resubmit(
|
||||
db: AsyncSession, record: Any, values: dict[str, Any], actor: User, assignment_model: Any, fk: str
|
||||
db: AsyncSession,
|
||||
record: Any,
|
||||
values: dict[str, Any],
|
||||
actor: User,
|
||||
assignment_model: Any | None = None,
|
||||
fk: str | None = None,
|
||||
) -> None:
|
||||
"""Re-send a rejected record with the MR's new details, assigned to that MR."""
|
||||
"""Re-send a rejected record with the MR's new details, assigned to that MR (stockists have no
|
||||
per-MR assignment: they belong to the headquarters)."""
|
||||
for field, value in values.items():
|
||||
setattr(record, field, value)
|
||||
record.approval_status = MasterApproval.PENDING
|
||||
record.requested_by_user_id = actor.id
|
||||
record.rejection_reason = None
|
||||
if assignment_model is None or fk is None:
|
||||
return
|
||||
today = date.today()
|
||||
current = (
|
||||
await db.execute(
|
||||
@@ -59,7 +67,7 @@ async def resubmit(
|
||||
|
||||
async def requests_for(db: AsyncSession, model: Any, actor: User) -> list[Any]:
|
||||
"""An MR: what they asked for that is still waiting or was rejected.
|
||||
An Area Manager: what waits for them. Administrator and GM: everything waiting."""
|
||||
An Area Business Manager: what waits for them. Administrator and AGM: everything waiting."""
|
||||
stmt = select(model).order_by(model.created_at.desc())
|
||||
if actor.role in FIELD_ROLES:
|
||||
return list(
|
||||
@@ -92,8 +100,8 @@ async def review(
|
||||
record = await db.get(model, record_id)
|
||||
if record is None:
|
||||
raise NotFoundError(f"{entity_type.value.capitalize()} not found")
|
||||
if actor.role not in (Role.AM, Role.ADMIN):
|
||||
raise ForbiddenError("Only the Area Manager approves a new doctor or chemist")
|
||||
if actor.role not in (Role.ABM, Role.ADMIN):
|
||||
raise ForbiddenError("Only the Area Business Manager approves a new doctor, chemist or stockist")
|
||||
await assert_can_view_hq(db, actor, record.headquarters_id)
|
||||
target = MasterApproval.APPROVED if approve else MasterApproval.REJECTED
|
||||
if record.approval_status == target:
|
||||
|
||||
Reference in New Issue
Block a user