本文整理匯總了Python中flask_wtf.FlaskForm.validate_on_submit方法的典型用法代碼示例。如果您正苦於以下問題:Python FlaskForm.validate_on_submit方法的具體用法?Python FlaskForm.validate_on_submit怎麽用?Python FlaskForm.validate_on_submit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類flask_wtf.FlaskForm
的用法示例。
在下文中一共展示了FlaskForm.validate_on_submit方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: show_reports
# 需要導入模塊: from flask_wtf import FlaskForm [as 別名]
# 或者: from flask_wtf.FlaskForm import validate_on_submit [as 別名]
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)
示例2: update_datacite
# 需要導入模塊: from flask_wtf import FlaskForm [as 別名]
# 或者: from flask_wtf.FlaskForm import validate_on_submit [as 別名]
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)
示例3: delete
# 需要導入模塊: from flask_wtf import FlaskForm [as 別名]
# 或者: from flask_wtf.FlaskForm import validate_on_submit [as 別名]
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)
示例4: email_verification_request
# 需要導入模塊: from flask_wtf import FlaskForm [as 別名]
# 或者: from flask_wtf.FlaskForm import validate_on_submit [as 別名]
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)