2020-05-24 18:30:57 -04:00
|
|
|
from flask_table import Table, Col, LinkCol, BoolCol, DatetimeCol, NestedTableCol
|
2020-02-14 15:19:30 -05:00
|
|
|
from flask_wtf import FlaskForm
|
2020-05-24 18:30:57 -04:00
|
|
|
from wtforms import SelectMultipleField, StringField, BooleanField, SelectField, validators, HiddenField
|
2020-02-17 16:21:18 -05:00
|
|
|
from wtforms_alchemy import ModelForm
|
2020-02-14 15:19:30 -05:00
|
|
|
|
2020-05-24 18:30:57 -04:00
|
|
|
from pb.models import RequiredDocument, Investigator, StudyDetails
|
2020-02-14 15:19:30 -05:00
|
|
|
|
|
|
|
|
|
|
|
class StudyForm(FlaskForm):
|
2020-03-30 09:34:42 -04:00
|
|
|
STUDYID = HiddenField()
|
2020-06-16 15:50:46 -04:00
|
|
|
TITLE = StringField('Title', [validators.DataRequired()])
|
|
|
|
NETBADGEID = StringField('User UVA Computing Id', [validators.DataRequired()])
|
2020-02-17 13:25:14 -05:00
|
|
|
requirements = SelectMultipleField("Requirements",
|
2020-02-28 11:16:12 -05:00
|
|
|
render_kw={'class': 'multi'},
|
2020-02-17 16:21:18 -05:00
|
|
|
choices=[(rd.AUXDOCID, rd.AUXDOC) for rd in RequiredDocument.all()])
|
|
|
|
HSRNUMBER = StringField('HSR Number')
|
|
|
|
Q_COMPLETE = BooleanField('Complete in Protocol Builder?', default='checked',
|
2020-02-17 13:25:14 -05:00
|
|
|
false_values=(False, 'false', 0, '0'))
|
2020-02-17 11:43:26 -05:00
|
|
|
|
2020-06-16 15:50:46 -04:00
|
|
|
|
2020-02-17 13:25:14 -05:00
|
|
|
class InvestigatorForm(FlaskForm):
|
2020-02-17 16:21:18 -05:00
|
|
|
NETBADGEID = StringField('UVA Id')
|
|
|
|
INVESTIGATORTYPE = SelectField("InvestigatorType", choices=[(i.INVESTIGATORTYPE, i.INVESTIGATORTYPEFULL) for i in Investigator.all_types()])
|
|
|
|
|
2020-06-16 15:50:46 -04:00
|
|
|
|
2020-02-17 16:21:18 -05:00
|
|
|
class StudyDetailsForm(ModelForm, FlaskForm):
|
|
|
|
class Meta:
|
|
|
|
model = StudyDetails
|
2020-02-17 11:43:26 -05:00
|
|
|
|
2020-06-16 15:50:46 -04:00
|
|
|
|
2020-06-30 14:48:11 -04:00
|
|
|
class ConfirmDeleteForm(FlaskForm):
|
|
|
|
confirm = BooleanField('Yes, really delete', default='checked',
|
|
|
|
false_values=(False, 'false', 0, '0'))
|
|
|
|
|
2020-02-17 11:43:26 -05:00
|
|
|
class RequirementsTable(Table):
|
2020-02-17 16:21:18 -05:00
|
|
|
AUXDOCID = Col('Code')
|
|
|
|
AUXDOC = Col('Name')
|
2020-02-14 15:19:30 -05:00
|
|
|
|
2020-06-16 15:50:46 -04:00
|
|
|
|
2020-02-17 13:25:14 -05:00
|
|
|
class InvestigatorsTable(Table):
|
2020-02-17 16:21:18 -05:00
|
|
|
NETBADGEID = Col('UVA Id')
|
|
|
|
INVESTIGATORTYPE = Col('Type')
|
2020-02-26 12:17:37 -05:00
|
|
|
delete = LinkCol(
|
|
|
|
'delete', 'del_investigator', url_kwargs=dict(inv_id='id'),
|
|
|
|
anchor_attrs={'class': 'btn btn-icon btn-warn', 'title': 'Delete Investigator'},
|
|
|
|
th_html_attrs={'class': 'mat-icon text-center', 'title': 'Delete Investigator'}
|
|
|
|
)
|
2020-02-17 13:25:14 -05:00
|
|
|
|
|
|
|
|
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
|
2020-02-26 12:17:37 -05:00
|
|
|
edit = LinkCol(
|
|
|
|
'edit', 'edit_study', url_kwargs=dict(study_id='STUDYID'),
|
|
|
|
anchor_attrs={'class': 'btn btn-icon btn-primary', 'title': 'Edit Study'},
|
|
|
|
th_html_attrs={'class': 'mat-icon text-center', 'title': 'Edit Study'}
|
|
|
|
)
|
|
|
|
details = LinkCol(
|
|
|
|
'ballot', 'study_details', url_kwargs=dict(study_id='STUDYID'),
|
|
|
|
anchor_attrs={'class': 'btn btn-icon btn-default', 'title': 'Edit Questions'},
|
|
|
|
th_html_attrs={'class': 'mat-icon text-center', 'title': 'Edit Questions'}
|
|
|
|
)
|
|
|
|
add_inv = LinkCol(
|
|
|
|
'person_add', 'new_investigator', url_kwargs=dict(study_id='STUDYID'),
|
|
|
|
anchor_attrs={'class': 'btn btn-icon btn-accent', 'title': 'Add Investigator'},
|
|
|
|
th_html_attrs={'class': 'mat-icon text-center', 'title': 'Add Investigator'}
|
|
|
|
)
|
2020-02-17 16:21:18 -05:00
|
|
|
STUDYID = Col('Study Id')
|
|
|
|
TITLE = Col('Title')
|
|
|
|
NETBADGEID = Col('User')
|
|
|
|
DATE_MODIFIED = DatetimeCol('Last Update', "medium")
|
|
|
|
Q_COMPLETE = BoolCol('Complete?')
|
2020-02-17 11:43:26 -05:00
|
|
|
requirements = NestedTableCol('Requirements', RequirementsTable)
|
2020-02-17 13:25:14 -05:00
|
|
|
investigators = NestedTableCol('Investigators', InvestigatorsTable)
|
2020-06-30 14:58:29 -04:00
|
|
|
delete = LinkCol(
|
|
|
|
'delete', 'del_study', url_kwargs=dict(study_id='STUDYID'),
|
|
|
|
anchor_attrs={'class': 'btn btn-icon btn-warn', 'title': 'Delete Study'},
|
|
|
|
th_html_attrs={'class': 'mat-icon text-center', 'title': 'Delete Study'}
|
|
|
|
)
|
2020-02-17 11:43:26 -05:00
|
|
|
|