FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 74c5c2ee authored by Dr Catherine Pitt's avatar Dr Catherine Pitt
Browse files

Reload supervisors list when safety form loaded

See RT 221400. The list of people who are allowed to sign off safety
forms is generated from the database. Because of the way WTForms works,
the list is set when the code to define the safety form class is first
run, and each safety form instance that is created gets the same list
from the class. This is annoying when new people have been added to the
list, as the applicaton doesn't see them until it restarts and hence
re-runs the code to define the class.

This change reloads the choices on the safety induction signer field on
instances of the safety form immediately after they are created in the
safety checklist view, thus immediately picking up new signers.
parent 9639cf09
No related branches found
No related tags found
No related merge requests found
Pipeline #239239 passed
......@@ -53,6 +53,11 @@ def safety_checklist_form():
safety_form = forms.SafetyChecklist(data=form_data)
else:
safety_form = forms.SafetyChecklistWithTraining(data=form_data)
# reload the supervisors choices from the database here, otherwise they may be stale
# as the initial list is created when the app first imports the form
safety_form.safety_induction_person_signing_off_id.choices = database.get_hids(
"supervisor", null_option=""
)
if request.method == "GET":
return render_template(
"safety/safety_form.html",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment