diff --git a/lung_cancer_screening/nhsuk_forms/imperial_weight_form.py b/lung_cancer_screening/nhsuk_forms/imperial_weight_field.py similarity index 100% rename from lung_cancer_screening/nhsuk_forms/imperial_weight_form.py rename to lung_cancer_screening/nhsuk_forms/imperial_weight_field.py diff --git a/lung_cancer_screening/nhsuk_forms/jinja2/imperial-weight-input.jinja b/lung_cancer_screening/nhsuk_forms/jinja2/imperial-weight-input.jinja index 0886e871..1ade15cf 100644 --- a/lung_cancer_screening/nhsuk_forms/jinja2/imperial-weight-input.jinja +++ b/lung_cancer_screening/nhsuk_forms/jinja2/imperial-weight-input.jinja @@ -31,7 +31,8 @@ "name": field.html_name + "_0", "value": field.subwidgets.0.data.value, "classes": "nhsuk-input--width-2" + field_error_classes, - "type": "number" + "type": "number", + "suffix": "st" }) }} @@ -46,7 +47,8 @@ "name": field.html_name + "_1", "value": field.subwidgets.1.data.value, "classes": "nhsuk-input--width-2" + field_error_classes, - "type": "number" + "type": "number", + "suffix": "lb" }) }} diff --git a/lung_cancer_screening/nhsuk_forms/tests/unit/test_imperial_height_field.py b/lung_cancer_screening/nhsuk_forms/tests/unit/test_imperial_height_field.py new file mode 100644 index 00000000..3a98a346 --- /dev/null +++ b/lung_cancer_screening/nhsuk_forms/tests/unit/test_imperial_height_field.py @@ -0,0 +1,40 @@ +from django.test import TestCase +from django.forms import Form +from ...imperial_height_field import ImperialHeightField + + +class TestImperialHeightField(TestCase): + def test_renders_nhs_input(self): + class TestForm(Form): + field = ImperialHeightField(label="Abc") + + self.assertHTMLEqual( + TestForm()["field"].as_field_group(), + """ +
+
+
+ +
+ + +
+
+
+ +
+
+ +
+ + +
+
+
+
+ """, + ) diff --git a/lung_cancer_screening/nhsuk_forms/tests/unit/test_imperial_weight_field.py b/lung_cancer_screening/nhsuk_forms/tests/unit/test_imperial_weight_field.py new file mode 100644 index 00000000..75db7de1 --- /dev/null +++ b/lung_cancer_screening/nhsuk_forms/tests/unit/test_imperial_weight_field.py @@ -0,0 +1,40 @@ +from django.test import TestCase +from django.forms import Form +from ...imperial_weight_field import ImperialWeightField + + +class TestImperialWeightField(TestCase): + def test_renders_nhs_input(self): + class TestForm(Form): + field = ImperialWeightField(label="Abc") + + self.assertHTMLEqual( + TestForm()["field"].as_field_group(), + """ +
+
+
+ +
+ + +
+
+
+ +
+
+ +
+ + +
+
+
+
+ """, + ) diff --git a/lung_cancer_screening/questions/forms/imperial_weight_form.py b/lung_cancer_screening/questions/forms/imperial_weight_form.py index 170a2343..d610d647 100644 --- a/lung_cancer_screening/questions/forms/imperial_weight_form.py +++ b/lung_cancer_screening/questions/forms/imperial_weight_form.py @@ -1,6 +1,6 @@ from django import forms -from ...nhsuk_forms.imperial_weight_form import ImperialWeightField +from ...nhsuk_forms.imperial_weight_field import ImperialWeightField from ..models.response_set import ResponseSet class ImperialWeightForm(forms.ModelForm): diff --git a/lung_cancer_screening/questions/forms/metric_weight_form.py b/lung_cancer_screening/questions/forms/metric_weight_form.py index 062c918f..8b4a8199 100644 --- a/lung_cancer_screening/questions/forms/metric_weight_form.py +++ b/lung_cancer_screening/questions/forms/metric_weight_form.py @@ -16,7 +16,8 @@ def __init__(self, *args, **kwargs): required=True, error_messages={ 'required': 'Enter your weight', - } + }, + suffix="kg" ) def clean_weight_metric(self): return self.cleaned_data['weight_metric'] * 10