Merge pull request #30 from sartography/feature/limit_investigator_options

Feature/limit investigator options
This commit is contained in:
Dan Funk 2020-08-17 16:34:34 -04:00 committed by GitHub
commit b8b8dd00b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -217,6 +217,16 @@ def edit_study(study_id):
@app.route('/investigator/<study_id>', methods=['GET', 'POST'])
def new_investigator(study_id):
form = InvestigatorForm(request.form)
# Remove options from form if unique investigator already exist, but AS_C and SI can happen many times.
investigators = db.session.query(Investigator).filter(Study.STUDYID == study_id).all()
choices = form.INVESTIGATORTYPE.choices
existing_types = [i.INVESTIGATORTYPE for i in investigators]
existing_types = list(filter(lambda a: a != "AS_C", existing_types))
existing_types = list(filter(lambda a: a != "SI", existing_types))
new_choices = [choice for choice in choices if choice[0] not in existing_types]
form.INVESTIGATORTYPE.choices = new_choices
action = BASE_HREF + "/investigator/" + study_id
title = "Add Investigator to Study " + study_id
if request.method == 'POST':