From f2040461d005205c005b54bd8a53283f5672552c Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Fri, 18 Jun 2021 14:43:59 -0400 Subject: [PATCH] Modify IRBInfoForm to use the new IRBEVENT and IRB_STATUS relationships. Have to define the form explicitly now, instead of automagically from the model. --- pb/forms.py | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/pb/forms.py b/pb/forms.py index b11cac2..8830138 100644 --- a/pb/forms.py +++ b/pb/forms.py @@ -2,8 +2,10 @@ from flask_table import Table, Col, LinkCol, BoolCol, DatetimeCol, NestedTableCo from flask_wtf import FlaskForm from wtforms import SelectMultipleField, StringField, BooleanField, SelectField, validators, HiddenField, DateField, IntegerField from wtforms_alchemy import ModelForm +from wtforms.widgets.html5 import DateInput +from wtforms.validators import Optional -from pb.models import RequiredDocument, Investigator, StudyDetails, IRBStatus, IRBInfo +from pb.models import RequiredDocument, Investigator, StudyDetails, IRBStatus, IRBInfo, IRBInfoEvent, IRBInfoStatus class StudyForm(FlaskForm): @@ -18,10 +20,31 @@ class StudyForm(FlaskForm): choices=[((q.STATUS, q.DETAIL), q.DETAIL) for q in IRBStatus.all()]) -class IRBInfoForm(ModelForm, FlaskForm): - class Meta: - model = IRBInfo - hidden = 'SS_STUDY_ID' +def irb_to_int(x): + if x == 'None': + return None + elif x == '0': + return 0 + elif x == '1': + return 1 + + +class IRBInfoForm(FlaskForm): + SS_STUDY_ID = HiddenField() + UVA_STUDY_TRACKING = StringField('UVA_STUDY_TRACKING') + DATE_MODIFIED = DateField('DATE_MODIFIED', [Optional()], widget=DateInput()) + IRB_ADMINISTRATIVE_REVIEWER = StringField('IRB_ADMINISTRATIVE_REVIEWER') + AGENDA_DATE = DateField('AGENDA_DATE', [Optional()], widget=DateInput()) + IRB_REVIEW_TYPE = StringField('IRB_REVIEW_TYPE') + IRBEVENT = SelectField("IRBInfoEvent", + choices=[((q.EVENT_ID, q.EVENT), q.EVENT) for q in IRBInfoEvent.all()]) + IRB_STATUS = SelectField("IRBInfoStatus", + choices=[((q.STATUS_ID, q.STATUS), q.STATUS) for q in IRBInfoStatus.all()]) + IRB_OF_RECORD = StringField('IRB_OF_RECORD') + UVA_IRB_HSR_IS_IRB_OF_RECORD_FOR_ALL_SITES = SelectField('UVA_IRB_HSR_IS_IRB_OF_RECORD_FOR_ALL_SITES', + choices=['None', '0', '1'], + coerce=irb_to_int) + STUDYIRBREVIEWERADMIN = StringField('STUDYIRBREVIEWERADMIN') class InvestigatorForm(FlaskForm):