Python flask_wtf.FlaskForm() Examples

The following are 6 code examples of flask_wtf.FlaskForm(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module flask_wtf , or try the search function .
Example #1
Source Project: notifications-admin   Author: alphagov   File: styleguide.py    License: MIT License 6 votes vote down vote up
def styleguide():

    if not current_app.config['SHOW_STYLEGUIDE']:
        abort(404)

    class FormExamples(Form):
        username = StringField(u'Username')
        password = PasswordField(u'Password', [validators.required()])
        code = StringField('Enter code')
        message = TextAreaField(u'Message')
        file_upload = FileField('Upload a CSV file to add your recipients’ details')

    sms = "Your vehicle tax for ((registration number)) is due on ((date)). Renew online at www.gov.uk/vehicle-tax"

    form = FormExamples()
    form.message.data = sms
    form.validate()

    template = SMSPreviewTemplate({'content': sms, 'template_type': 'sms'})

    return render_template(
        'views/styleguide.html',
        form=form,
        template=template
    ) 
Example #2
Source Project: flaskapp   Author: muicss   File: auth.py    License: MIT License 5 votes vote down vote up
def email_verification_request():
    """GET|POST /email-verification-request: handle email verification requests
    """
    u = g.user

    form = FlaskForm()
    if form.validate_on_submit():
        send_verification_email(u)
        fn = '/auth/email-verification-request-followup.html'
        return render_template(fn, email=u.email)

    return render_template('/auth/email-verification-request.html', form=form) 
Example #3
Source Project: etesync-dav   Author: etesync   File: webui.py    License: GNU General Public License v3.0 5 votes vote down vote up
def logout():
    form = FlaskForm(request.form)
    if form.validate_on_submit():
        logout_user()

    return redirect(url_for('login'))


# FIXME: hack to kill server after generation. 
Example #4
Source Project: etesync-dav   Author: etesync   File: webui.py    License: GNU General Public License v3.0 5 votes vote down vote up
def shutdown():
    form = FlaskForm(request.form)
    if form.validate_on_submit():
        return shutdown_response()

    return redirect(url_for('login')) 
Example #5
Source Project: etesync-dav   Author: etesync   File: webui.py    License: GNU General Public License v3.0 5 votes vote down vote up
def certgen():
    if request.method == 'GET':
        return redirect(url_for('account_list'))

    form = FlaskForm(request.form)
    if form.validate_on_submit():
        generate_cert()
        macos_trust_cert()

        return shutdown_response()

    return redirect(url_for('account_list')) 
Example #6
Source Project: buku   Author: jarun   File: views.py    License: GNU General Public License v3.0 5 votes vote down vote up
def scaffold_form(self):
        class CustomForm(FlaskForm):  # pylint: disable=too-few-public-methods
            name = wtforms.StringField(validators=[wtforms.validators.DataRequired()])

        return CustomForm