Skip to content

Commit 384ee88

Browse files
committed
make mandatory fields customisable by marking session
1 parent fdcdb90 commit 384ee88

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

ceuk-marking/settings.py

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
if hasattr(local_config, "FORM_HINTS"):
5656
FORM_HINTS = local_config.FORM_HINTS
5757

58+
MANDATORY_FIELDS = {}
59+
if hasattr(local_config, "MANDATORY_FIELDS"):
60+
MANDATORY_FIELDS = local_config.MANDATORY_FIELDS
61+
5862
# make sure CSRF checking still works behind load balancers
5963
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
6064

crowdsourcer/forms.py

+10
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ def __init__(self, *args, **kwargs):
7878
if form_hints.get(field):
7979
self.fields[field].help_text = form_hints[field]
8080

81+
mandatory_fields = settings.MANDATORY_FIELDS.get(
82+
self.question_obj.section.marking_session.label, {}
83+
)
84+
85+
if mandatory_fields.get("mandatory_if_response"):
86+
self.mandatory_if_response = mandatory_fields["mandatory_if_response"]
87+
88+
if mandatory_fields.get("mandatory_if_no"):
89+
self.mandatory_if_response = mandatory_fields["mandatory_if_no"]
90+
8191
def clean_page_number(self):
8292
page_number = self.cleaned_data["page_number"]
8393
if page_number == "" or page_number is None:

0 commit comments

Comments
 (0)