Source code for app.view.forms.upload_step3_form

from wtforms import (
    BooleanField,
    FieldList,
    FormField,
    SelectMultipleField,
    StringField,
)
from wtforms.validators import DataRequired, Length

from app.view.forms.base_form import BaseForm
from app.model.orm import StudyTechnique


[docs] class UploadStep3Form(BaseForm):
[docs] class Meta:
[docs] csrf_time_limit = None
[docs] class TechniqueForm(BaseForm):
[docs] class Meta:
[docs] csrf = False
[docs] type = StringField('type', validators=[DataRequired()])
[docs] subjectType = StringField('subjectType', validators=[DataRequired()])
[docs] label = StringField('label', validators=[Length(max=100)])
[docs] units = StringField('units')
[docs] description = StringField('description')
[docs] metaboliteIds = SelectMultipleField('metaboliteIds', choices=[], validate_choice=False)
[docs] includeStd = BooleanField('includeStd')
[docs] includeUnknown = BooleanField('includeUnknown')
[docs] includeLive = BooleanField('includeLive')
[docs] includeDead = BooleanField('includeDead')
[docs] includeTotal = BooleanField('includeTotal')
[docs] techniques = FieldList(FormField(TechniqueForm))
[docs] def validate_techniques(self, field): techniques = [ StudyTechnique( type=t['type'], label=t['label'], subjectType=t['subjectType'], ) for t in field.data ] technique_descriptions = [st.long_name_with_subject_type for st in techniques] self._validate_uniqueness("technique_properties", "not unique", technique_descriptions)