当前位置: 首页>>代码示例>>Python>>正文


Python flask_wtf.FlaskForm类代码示例

本文整理汇总了Python中flask_wtf.FlaskForm的典型用法代码示例。如果您正苦于以下问题:Python FlaskForm类的具体用法?Python FlaskForm怎么用?Python FlaskForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FlaskForm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: show_reports

def show_reports():

    form = FlaskForm()
    if form.validate_on_submit():

        vcf_id = request.form['vcfs'].split(',')[0]
        url = urlparse.urlparse(request.form['url'])
        args = MultiDict(urlparse.parse_qsl(url.query))
        response = jsonapi.get_related(db, args, 'vcfs', vcf_id, 'calls')
        title = request.form.get('title')
        if response.status == requests.codes.ok:
            report = Report(title)
            report.vcfs = [VCF.query.get(vcf_id)]
            report.creator = current_user
            report.project = Project.query.get(request.form.get('project'))
            report.panels = Panel.query.filter(Panel.id.in_(request.form.get('panels').split(','))).all()
            report.fisher = request.form.get('fisher')
            report.artifact = request.form.get('artifact')
            report.frequency = request.form.get('frequency')
            report.depth = request.form.get('depth')
            report.content = cPickle.dumps(response.document)
            db.add(report)
            try:
                db.commit()
            except SQLAlchemyError:
                flash("Error saving report: '{0}'. Please try again later.".format(title), category='danger')
            else:
                flash("Report: '{0}' saved successfully.".format(title), category='success')

    admin = current_user.is_authenticated and PERMISSION.MANAGE_REPORT_REQUEST in current_user.permissions
    return render_template('reports/index.html', admin=admin)
开发者ID:zabano,项目名称:dx,代码行数:31,代码来源:view.py

示例2: update_datacite

    def update_datacite(self):
        """."""
        form = UpdateDataciteForm()
        cancel_or_new_task_form = FlaskForm()

        is_task_running = False
        time = 0
        task_details = current_cache.get('update_datacite:task_details')

        if task_details:
            is_task_running = True
            if cancel_or_new_task_form.validate_on_submit():
                current_cache.set('update_datacite:task_details', None)
                return redirect(url_for('updatedataciteview.update_datacite'))
        else:
            if form.validate_on_submit():
                from_date = request.form['from_date']
                until_date = request.form['until_date']

                action = request.form['action']
                if action == 'SubmitDates':
                    if from_date > until_date:
                        flash("Error: the 'From' date should precede the 'Until' date.")
                    else:
                        pids_count = find_registered_doi_pids(from_date,
                                                                until_date,
                                                                current_app.config['ZENODO_LOCAL_DOI_PREFIXES']).count()
                        task_details = dict(
                            total_pids=pids_count
                        )
                        time = pids_count/current_app.config['DATACITE_UPDATING_RATE_PER_HOUR']

                elif action == 'Confirm':
                    pids_count = find_registered_doi_pids(from_date,
                                                          until_date,
                                                          current_app.config['ZENODO_LOCAL_DOI_PREFIXES']).count()
                    task_details = dict(
                        start_date=datetime.utcnow(),
                        job_id=str(uuid.uuid4()),
                        from_date=from_date,
                        until_date=until_date,
                        total_pids=pids_count,
                        left_pids=pids_count,
                        last_update=datetime.utcnow()
                    )
                    current_cache.set('update_datacite:task_details',
                                      task_details, timeout=-1)
                    return redirect(url_for('updatedataciteview.update_datacite'))

                elif action == 'Cancel':
                    return redirect(url_for('updatedataciteview.update_datacite'))

        return self.render('zenodo_records/update_datacite.html',
                           form=form,
                           cancel_or_new_task_form=cancel_or_new_task_form,
                           details=task_details,
                           is_task_running=is_task_running, time=time)
开发者ID:slint,项目名称:zenodo,代码行数:57,代码来源:admin.py

示例3: delete

def delete(id):
    item = Transcript.query.get_or_404(id)
    form = FlaskForm()

    if form.validate_on_submit():
        db.session.delete(item)
        db.session.commit()
        return redirect_for('transcript.index')

    return render_template('transcript/delete.html', item=item, form=form)
开发者ID:sopython,项目名称:sopython-site,代码行数:10,代码来源:views.py

示例4: email_verification_request

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)
开发者ID:muicss,项目名称:flaskapp,代码行数:12,代码来源:auth.py

示例5: validate

 def validate(self):
     rv = FlaskForm.validate(self)
     if not rv:
         return False
     if len(str(self.postalcode.data)) is 5 and int(self.postalcode.data):
         return True
     self.postalcode.data = re.sub(r'\s', r'', self.postalcode.data)
     if not len(str(self.postalcode.data)) is 6:
         self.postalcode.errors.append('Invalid postal code (length)')
         return False
     if not ''.join([
         str(self.postalcode.data)[0],
         str(self.postalcode.data)[2],
         str(self.postalcode.data)[4]
     ]).isalpha():
         self.postalcode.errors.append(
             'Invalid postal code (example: A1A1A1)'
         )
         return False
     if not ''.join([
         str(self.postalcode.data)[1],
         str(self.postalcode.data)[3],
         str(self.postalcode.data)[5]
     ]).isdigit():
         self.postalcode.errors.append(
             'Invalid postal code (example: A1A1A1)'
         )
         return False
     return True
开发者ID:BenChaimberg,项目名称:swingflask,代码行数:29,代码来源:forms.py

示例6: validate

    def validate(self):

        # Validate all other fields with default validators
        if not FlaskForm.validate(self):
            return False
        result = True

        archive_date = self.archive_date.data
        publish_date = self.publish_date.data
        if archive_date and publish_date > archive_date:
            self.archive_date.errors.append(
                _('Archive date needs to be after the publish date.'))
            result = False

        # Test if either english or dutch is entered
        if not (self.nl_title.data or self.en_title.data):
            self.nl_title.errors.append(
                _('Either Dutch or English title required'))
            result = False
        if not (self.nl_content.data or self.en_content.data):
            self.nl_content.errors.append(
                _('Either Dutch or English content required'))
            result = False

        # XOR the results to test if both of a language was given
        if bool(self.nl_title.data) != bool(self.nl_content.data):
            self.nl_title.errors.append(
                _('Dutch title requires Dutch content and vice versa'))
            result = False
        if bool(self.en_title.data) != bool(self.en_content.data):
            self.en_title.errors.append(
                _('English title requires English content and vice versa'))
            result = False

        return result
开发者ID:viaict,项目名称:viaduct,代码行数:35,代码来源:news.py

示例7: validate

 def validate(self):
     rv = FlaskForm.validate(self)
     if rv is None:
         return False
     user = authenticate_user(current_user.username, self.password.data)
     if user is None:
         return False
     return True
开发者ID:zifnab06,项目名称:zifb.in,代码行数:8,代码来源:auth.py

示例8: validate

 def validate(self):
     if not FlaskForm.validate(self):
         return False
     user = User.query.filter_by(email = self.email.data.lower()).first()
     if user:
         self.email.errors.append("That email is already taken")
         return False
     else:
         return True
开发者ID:AlvinCJin,项目名称:RealEstateApp,代码行数:9,代码来源:forms.py

示例9: validate

    def validate(self):
        if not FlaskForm.validate(self):
            return False

        if self.open.data:
            self.desired_state = DoorState.Open
        elif self.present.data:
            self.desired_state = DoorState.Present

        return True
开发者ID:Binary-Kitchen,项目名称:doorlockd,代码行数:10,代码来源:WebApp.py

示例10: validate

    def validate(self):
        rv = FlaskForm.validate(self)
        if not rv:
            return False

        user = User.get_user(self.username.data)
        if user and user.username.lower() != g.user.username.lower():
            self.username.errors.append('Username already in use')
            return False

        return True
开发者ID:axula,项目名称:pfcharactersheet,代码行数:11,代码来源:forms.py

示例11: validate

    def validate(self):
        # check default validation
        if not FlaskForm.validate(self):
            return False

        # check nested forms
        for t in self.target_set:
            if not t.form.validate():
                error_fields = ','.join(t.form.errors.keys())
                self.target_set.errors.append({'target': t.name, 'message': 'Invalid target ' + error_fields})
                return False

        return True
开发者ID:18mr,项目名称:call-congress,代码行数:13,代码来源:forms.py

示例12: validate

    def validate(self):
        if not FlaskForm.validate(self):
            print "wrong two"
            return False

        user = User.query.filter_by(username=self.username.data).first()
        if user and user.verify_password(self.password_hash.data):
            return True

        else:
            flash('invalid username or password')
            self.username.errors.append("Invalid username or password")
            return False
开发者ID:eddwinn,项目名称:searchAnon,代码行数:13,代码来源:forms.py

示例13: validate

    def validate(self):

        # Validate all other fields with default validators
        if not FlaskForm.validate(self):
            return False

        # Test if either english or dutch is entered
        if self.start_time.data >= self.end_time.data:
            self.start_time.errors.append(
                _("Start time must be before end time"))
            # Append empty string to mark the field red.
            self.end_time.errors.append('')
            return False

        return True
开发者ID:viaict,项目名称:viaduct,代码行数:15,代码来源:activity.py

示例14: validate

    def validate(self, *args, **kwargs):
        """
        Validates the form by calling `validate` on each field, passing any
        extra `Form.validate_<fieldname>` validators to the field validator.

        also calls `validate_ldap`
        """

        valid = FlaskForm.validate(self, *args, **kwargs)
        if not valid:
            logging.debug("Form validation failed before we had a change to "
                          "check ldap. Reasons: '{0}'".format(self.errors))
            return valid

        return self.validate_ldap()
开发者ID:mwielgoszewski,项目名称:flask-ldap3-login,代码行数:15,代码来源:forms.py

示例15: validate

 def validate(self):
     rv = FlaskForm.validate(self)
     if not rv:
         return False
     if self.action.data not in ('edit', 'new'):
         return False
     has_error = False
     if self.action.data in ('edit', 'new'):
         if type(self.name.data) not in (str, unicode) or not re.search(r'[A-Za-z0-9]', self.name.data):
             self.name.errors.append(word("The name must be filled in."))
             has_error = True
         if type(self.method.data) not in (str, unicode) or self.method.data not in ('referer', 'ip', 'none'):
             self.name.errors.append(word("You must select an option."))
             has_error = True
     if has_error:
         return False
     return True
开发者ID:Gauntlet173,项目名称:docassemble,代码行数:17,代码来源:develop.py


注:本文中的flask_wtf.FlaskForm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。