class DetermineDescriptorTypesForm(Form): descriptor_types = FieldList( RadioField(choices=[ ('text', 'Text'), ('option', 'Option'), ('hyperlink', 'Hyperlink'), ], validators=[InputRequired()])) navigation = FormField(NavigationForm)
def change_required_option_descriptor(): descriptors = Descriptor.query.all() choices = [] for d in descriptors: if d.values: choices.append((d.name, d.name)) req_opt_desc = RequiredOptionDescriptor.query.all()[0] current_name = "" if req_opt_desc.descriptor_id != -1: descriptor = Descriptor.query.filter_by( id=req_opt_desc.descriptor_id ).first() if descriptor is not None: current_name = descriptor.name if current_name != "": setattr( ChangeRequiredOptionDescriptorForm, 'descriptor', SelectField( 'Option Descriptor', choices=choices, validators=[InputRequired()], default=current_name) ) form = ChangeRequiredOptionDescriptorForm() if form.validate_on_submit(): RequiredOptionDescriptorConstructor.query.delete() db.session.commit() desc = Descriptor.query.filter_by( name=form.descriptor.data ).first() if desc is not None: req_opt_desc_const = RequiredOptionDescriptorConstructor(name=desc.name, values=desc.values) db.session.add(req_opt_desc_const) db.session.commit() return redirect(url_for('descriptor.review_required_option_descriptor')) else: form = None return render_template( 'descriptor/change_required_option_descriptor.html', form=form )
class RequiredOptionDescriptorMissingForm(Form): resources = FieldList(SelectMultipleField(validators=[InputRequired()])) navigation = FormField(NavigationForm)
class DetermineRequiredOptionDescriptorForm(Form): required_option_descriptor = SelectField('Required Option Descriptor', validators=[InputRequired()]) navigation = FormField(NavigationForm)
class VerifyAddressForm(Form): address = StringField('Address', validators=[InputRequired(), Length(1, 500)]) submit = SubmitField('Verify')