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
+1 -1
View File
@@ -43,7 +43,7 @@ def test_identity_is_gathered_from_all_rows_not_just_the_first():
# Headings exactly as printed on the company forms, in printed order.
PRINTED_HEADERS = {
"tour_plan": ["Sl.No.", "Date", "From", "To", "POB", "Stockiest Visit"],
"tour_plan": ["Sl.No.", "Date", "From", "To", "POB", "Stockist Visit"],
"standard_tour_plan": ["Sl.No.", "PLACE"],
"fare_chart": ["Sl.No.", "Date", "From", "To", "Kilometers (KM)\n(One Way)"],
"area_covered": ["AREA TO COVER", "SALE OBJECTIVE", "STATUS"],
+15
View File
@@ -98,3 +98,18 @@ class TestSignatures:
def test_user_text_is_escaped(self):
html = _render(_context([_doctor("<script>alert(1)</script>")]))
assert "<script>" not in html
class TestStockistVisits:
def test_stockist_table_printed_only_when_stockists_were_visited(self):
assert "NAME OF THE STOCKIST" not in _render(_context([_doctor("Dr Sen")]))
dcr = NS(
mr=NS(full_name="Sumit Patel", employee_code="MR001"), headquarters=NS(name="Bhubaneswar"),
report_date=date(2026, 9, 21), stockist_visit="", order_value="", mr_remarks="",
)
stockist = NS(stockist=NS(name="Ganesh Distributors"), pob="12000", visit_time=datetime(2026, 9, 21, 11, 0).time())
done = _render(build_dcr_context(dcr, [_doctor("Dr Sen")], [], None, None, [stockist]))
assert "NAME OF THE STOCKIST" in done and "Ganesh Distributors" in done and "12000" in done
dcr.report_type = "PLAN"
plan = _render(build_dcr_context(dcr, [], [], None, None, [stockist]))
assert "STOCKISTS TO VISIT" in plan and "11:00" in plan
+13 -13
View File
@@ -14,40 +14,40 @@ from app.common.exceptions import (
class TestHappyPath:
def test_mr_submits_draft(self):
t = assert_transition(DCRStatus.DRAFT, WorkflowAction.SUBMIT, Role.MR)
assert t.to_status == DCRStatus.PENDING_AM
assert t.to_status == DCRStatus.PENDING_ABM
def test_mr_resubmits_returned(self):
t = assert_transition(DCRStatus.RETURNED, WorkflowAction.SUBMIT, Role.MR)
assert t.to_status == DCRStatus.PENDING_AM
assert t.to_status == DCRStatus.PENDING_ABM
def test_am_approves(self):
t = assert_transition(DCRStatus.PENDING_AM, WorkflowAction.APPROVE, Role.AM)
t = assert_transition(DCRStatus.PENDING_ABM, WorkflowAction.APPROVE, Role.ABM)
assert t.to_status == DCRStatus.APPROVED
def test_am_returns_requires_reason(self):
t = assert_transition(DCRStatus.PENDING_AM, WorkflowAction.RETURN, Role.AM)
t = assert_transition(DCRStatus.PENDING_ABM, WorkflowAction.RETURN, Role.ABM)
assert t.to_status == DCRStatus.RETURNED
assert t.requires_reason is True
def test_gm_cannot_approve_or_return(self):
for action in (WorkflowAction.APPROVE, WorkflowAction.RETURN):
with pytest.raises(ForbiddenError):
assert_transition(DCRStatus.PENDING_AM, action, Role.GM)
assert_transition(DCRStatus.PENDING_ABM, action, Role.AGM)
class TestAreaManagerIsTheFinalApprover:
"""There is no General Manager stage: the AM approves or returns."""
"""There is no AGM stage: the ABM approves or returns."""
def test_no_general_manager_status_or_action_exists(self):
assert "PENDING_GM" not in {s.value for s in DCRStatus}
assert "FORWARD" not in {a.value for a in WorkflowAction}
assert not [t for t in TRANSITIONS if t.allowed_role == Role.GM]
assert not [t for t in TRANSITIONS if t.allowed_role == Role.AGM]
def test_only_the_area_manager_can_decide_a_pending_report(self):
for role in (Role.MR, Role.GM, Role.ADMIN):
for role in (Role.MR, Role.AGM, Role.ADMIN):
for action in (WorkflowAction.APPROVE, WorkflowAction.RETURN):
with pytest.raises(ForbiddenError):
assert_transition(DCRStatus.PENDING_AM, action, role)
assert_transition(DCRStatus.PENDING_ABM, action, role)
class TestAdminCanNeverApprove:
@@ -80,7 +80,7 @@ class TestEditability:
def test_editable(self, status):
assert_editable(status) # must not raise
@pytest.mark.parametrize("status", [DCRStatus.PENDING_AM, DCRStatus.APPROVED])
@pytest.mark.parametrize("status", [DCRStatus.PENDING_ABM, DCRStatus.APPROVED])
def test_not_editable(self, status):
with pytest.raises(ReportLockedError):
assert_editable(status)
@@ -89,11 +89,11 @@ class TestEditability:
class TestWrongRoleAtRightStage:
def test_mr_cannot_approve(self):
with pytest.raises(ForbiddenError):
assert_transition(DCRStatus.PENDING_AM, WorkflowAction.APPROVE, Role.MR)
assert_transition(DCRStatus.PENDING_ABM, WorkflowAction.APPROVE, Role.MR)
def test_gm_cannot_submit(self):
with pytest.raises(ForbiddenError):
assert_transition(DCRStatus.DRAFT, WorkflowAction.SUBMIT, Role.GM)
assert_transition(DCRStatus.DRAFT, WorkflowAction.SUBMIT, Role.AGM)
def test_mr_cannot_return_its_own_report(self):
with pytest.raises(InvalidStateTransitionError):
@@ -101,6 +101,6 @@ class TestWrongRoleAtRightStage:
def test_exactly_four_transitions():
"""submit (x2), then the Area Manager approves or returns."""
"""submit (x2), then the Area Business Manager approves or returns."""
assert len(TRANSITIONS) == 4
assert len(DCRStatus) == 4