Skip to content

Commit 137803b

Browse files
committed
Fix form labels
1 parent 8b77d53 commit 137803b

1 file changed

Lines changed: 18 additions & 12 deletions

File tree

  • manage_breast_screening/record_a_mammogram

manage_breast_screening/record_a_mammogram/forms.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from django import forms
22

3+
34
class ScreeningAppointmentForm(forms.Form):
45
decision = forms.ChoiceField(
56
choices=(
@@ -17,8 +18,8 @@ def save(self):
1718
class AskForMedicalInformationForm(forms.Form):
1819
decision = forms.ChoiceField(
1920
choices=(
20-
("continue", "Yes, mark incomplete sections as ‘none’ or ‘no’"),
21-
("dropout", "No, screening cannot proceed"),
21+
("continue", "Yes"),
22+
("dropout", "No - proceed to imaging"),
2223
),
2324
required=True,
2425
widget=forms.RadioSelect(),
@@ -31,7 +32,7 @@ def save(self):
3132
class RecordMedicalInformationForm(forms.Form):
3233
decision = forms.ChoiceField(
3334
choices=(
34-
("continue", "Yes, go to medical information"),
35+
("continue", "Yes, mark incomplete sections as ‘none’ or ‘no’"),
3536
("dropout", "No, screening cannot proceed"),
3637
),
3738
required=True,
@@ -58,9 +59,9 @@ class AppointmentCannotGoAheadForm(forms.Form):
5859
)
5960

6061
def __init__(self, *args, **kwargs):
61-
if 'instance' not in kwargs:
62+
if "instance" not in kwargs:
6263
raise ValueError("AppointmentCannotGoAheadForm requires an instance")
63-
self.instance = kwargs.pop('instance')
64+
self.instance = kwargs.pop("instance")
6465
super().__init__(*args, **kwargs)
6566

6667
# Dynamically add detail fields for each choice
@@ -72,7 +73,7 @@ def __init__(self, *args, **kwargs):
7273
required=True,
7374
error_messages={
7475
"required": "A reason for why this appointment cannot continue must be provided"
75-
}
76+
},
7677
)
7778

7879
decision = forms.ChoiceField(
@@ -84,26 +85,31 @@ def __init__(self, *args, **kwargs):
8485
widget=forms.RadioSelect(),
8586
error_messages={
8687
"required": "Select whether the participant needs to be invited for another appointment"
87-
}
88+
},
8889
)
8990

9091
def clean(self):
9192
cleaned_data = super().clean()
9293

93-
if 'stopped_reasons' in cleaned_data and 'other' in cleaned_data['stopped_reasons']:
94-
if not cleaned_data.get('other_details'):
95-
self.add_error('other_details', 'Explain why this appointment cannot proceed')
94+
if (
95+
"stopped_reasons" in cleaned_data
96+
and "other" in cleaned_data["stopped_reasons"]
97+
):
98+
if not cleaned_data.get("other_details"):
99+
self.add_error(
100+
"other_details", "Explain why this appointment cannot proceed"
101+
)
96102
return cleaned_data
97103

98104
def save(self):
99105
reasons_json = {}
100106
reasons_json["stopped_reasons"] = self.cleaned_data["stopped_reasons"]
101107
for field_name, value in self.cleaned_data.items():
102-
if field_name.endswith('_details') and value:
108+
if field_name.endswith("_details") and value:
103109
reasons_json[field_name] = value
104110
self.instance.stopped_reasons = reasons_json
105111
self.instance.reinvite = self.cleaned_data["decision"]
106112
self.instance.status = self.instance.Status.ATTENDED_NOT_SCREENED
107113
self.instance.save()
108114

109-
return self.instance
115+
return self.instance

0 commit comments

Comments
 (0)