2020-02-17 11:43:26 -05:00
|
|
|
from flask_table import Table, Col, DateCol, LinkCol, BoolCol, DatetimeCol, NestedTableCol
|
2020-02-14 15:19:30 -05:00
|
|
|
from flask_wtf import FlaskForm
|
2020-02-17 13:25:14 -05:00
|
|
|
from wtforms import SelectMultipleField, SubmitField, StringField, IntegerField, BooleanField, DateField, widgets, \
|
|
|
|
SelectField
|
2020-02-14 15:19:30 -05:00
|
|
|
|
2020-02-17 13:25:14 -05:00
|
|
|
from models import RequiredDocument, Investigator
|
2020-02-14 15:19:30 -05:00
|
|
|
|
|
|
|
|
|
|
|
class StudySearchForm(FlaskForm):
|
|
|
|
search = StringField('')
|
|
|
|
|
|
|
|
|
|
|
|
class StudyForm(FlaskForm):
|
|
|
|
title = StringField('Title')
|
2020-02-17 11:43:26 -05:00
|
|
|
netbadge_id = StringField('UVA Id for Primary Investigator')
|
2020-02-17 13:25:14 -05:00
|
|
|
requirements = SelectMultipleField("Requirements",
|
|
|
|
render_kw={'class':'multi'},
|
|
|
|
choices=[(rd.code, rd.name) for rd in RequiredDocument.all()])
|
2020-02-17 11:43:26 -05:00
|
|
|
hsr_number = StringField('HSR Number')
|
2020-02-17 13:25:14 -05:00
|
|
|
q_complete = BooleanField('Complete in Protocol Builder?', default='checked',
|
|
|
|
false_values=(False, 'false', 0, '0'))
|
2020-02-17 11:43:26 -05:00
|
|
|
# last_updated = DateField('Last Updated')
|
|
|
|
|
2020-02-17 13:25:14 -05:00
|
|
|
class InvestigatorForm(FlaskForm):
|
|
|
|
netbadge_id = StringField('UVA Id')
|
|
|
|
type = SelectField("InvestigatorType", choices=[(i.type, i.description) for i in Investigator.all_types()])
|
2020-02-17 11:43:26 -05:00
|
|
|
|
|
|
|
class RequirementsTable(Table):
|
|
|
|
code = Col('Code')
|
|
|
|
name = Col('Name')
|
2020-02-14 15:19:30 -05:00
|
|
|
|
2020-02-17 13:25:14 -05:00
|
|
|
class InvestigatorsTable(Table):
|
|
|
|
netbadge_id = Col('UVA Id')
|
|
|
|
type = Col('Type')
|
|
|
|
delete = LinkCol('Delete', 'del_investigator', url_kwargs=dict(inv_id='id'))
|
|
|
|
|
|
|
|
|
2020-02-14 15:19:30 -05:00
|
|
|
class StudyTable(Table):
|
2020-02-17 11:43:26 -05:00
|
|
|
def sort_url(self, col_id, reverse=False):
|
|
|
|
pass
|
|
|
|
edit = LinkCol('Edit', 'edit_study', url_kwargs=dict(study_id='study_id'))
|
2020-02-17 13:25:14 -05:00
|
|
|
delete = LinkCol('Delete', 'del_study', url_kwargs=dict(study_id='study_id'))
|
|
|
|
add_inv = LinkCol('Add Person', 'new_investigator', url_kwargs=dict(study_id='study_id'))
|
2020-02-17 11:43:26 -05:00
|
|
|
study_id = Col('Study Id')
|
|
|
|
title = Col('Title')
|
2020-02-17 13:25:14 -05:00
|
|
|
netbadge_id = Col('User')
|
2020-02-17 11:43:26 -05:00
|
|
|
last_updated = DatetimeCol('Last Update', "medium")
|
|
|
|
q_complete = BoolCol('Complete?')
|
|
|
|
requirements = NestedTableCol('Requirements', RequirementsTable)
|
2020-02-17 13:25:14 -05:00
|
|
|
investigators = NestedTableCol('Investigators', InvestigatorsTable)
|
2020-02-17 11:43:26 -05:00
|
|
|
|