Skip to content

Commit 7cb5280

Browse files
committed
append counters when there are multiple cyst items
This is visually hidden, and ensures that we don't have multiple links close together that are hard to distinguish by users of assistive tech
1 parent 519ed99 commit 7cb5280

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

manage_breast_screening/mammograms/presenters/medical_information_presenter.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,15 @@ def __init__(self, appointment):
6060
BenignLumpHistoryItemPresenter(item)
6161
for item in appointment.benign_lump_history_items.all()
6262
]
63-
self.cyst_history = [
64-
CystHistoryItemPresenter(item)
65-
for item in appointment.cyst_history_items.all()
66-
]
63+
64+
cyst_history_items = list(appointment.cyst_history_items.all())
65+
if len(cyst_history_items) == 1:
66+
self.cyst_history = [CystHistoryItemPresenter(cyst_history_items[0])]
67+
else:
68+
self.cyst_history = [
69+
CystHistoryItemPresenter(item, counter=counter)
70+
for counter, item in enumerate(cyst_history_items, 1)
71+
]
6772
self.existing_symptom_type_ids = {
6873
symptom.symptom_type_id for symptom in symptoms
6974
}

manage_breast_screening/mammograms/tests/presenters/test_medical_information_presenter.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
)
1010
from manage_breast_screening.participants.tests.factories import (
1111
AppointmentFactory,
12+
CystHistoryItemFactory,
1213
SymptomFactory,
1314
)
1415

@@ -114,6 +115,28 @@ def test_add_nipple_change_link(self):
114115
"text": "Add another nipple change",
115116
}
116117

118+
def test_cyst_history_items_have_a_counter(self):
119+
appointment = AppointmentFactory()
120+
CystHistoryItemFactory.create_batch(2, appointment=appointment)
121+
122+
counters = [
123+
item.counter
124+
for item in MedicalInformationPresenter(appointment).cyst_history
125+
]
126+
127+
assert counters == [1, 2]
128+
129+
def test_single_cyst_history_item_has_no_counter(self):
130+
appointment = AppointmentFactory()
131+
CystHistoryItemFactory.create(appointment=appointment)
132+
133+
counters = [
134+
item.counter
135+
for item in MedicalInformationPresenter(appointment).cyst_history
136+
]
137+
138+
assert counters == [None]
139+
117140
def test_implanted_medical_device_history_link(self):
118141
appointment = AppointmentFactory()
119142

0 commit comments

Comments
 (0)