本文整理汇总了Python中forms.SearchForm.validate_on_submit方法的典型用法代码示例。如果您正苦于以下问题:Python SearchForm.validate_on_submit方法的具体用法?Python SearchForm.validate_on_submit怎么用?Python SearchForm.validate_on_submit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.SearchForm
的用法示例。
在下文中一共展示了SearchForm.validate_on_submit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: raw_email
# 需要导入模块: from forms import SearchForm [as 别名]
# 或者: from forms.SearchForm import validate_on_submit [as 别名]
def raw_email(stype,docnumber):
#Get the raw email from the database
db_name = '01_database/hrc.sqlite'
db = sqlite3.connect(db_name)
cursor = db.cursor()
#search = docnumber
sql_cmd = 'SELECT RawText FROM emails\
WHERE DocNumber IS ?'
cursor.execute(sql_cmd, (docnumber,))
tmp = cursor.fetchone()
raw_email = tmp[0]
#Remove special characters and split into lines:
evec = raw_email.split('\n')
for line in evec:
line.strip()
#Take care of search form
form = SearchForm()
if form.validate_on_submit():# and request.method == 'POST':
flash('Searching Hillary\'s emails for "%s"' %
(form.search.data ))
#stype as placeholder in case we want to add different seach schemes
#'bs' = body/subject
#'ps' = people search
#'es' = email search (to/from address)
return redirect(url_for('.search', stype = stype, search = form.search.data))
return render_template('raw_email.html',
raw_email = evec,
docnumber = docnumber,
form = form)
示例2: search
# 需要导入模块: from forms import SearchForm [as 别名]
# 或者: from forms.SearchForm import validate_on_submit [as 别名]
def search():
""" Search form """
search = SearchForm()
if search.validate_on_submit():
return redirect(url_for('.search_results', query=search.search.data))
else:
return redirect(request.referrer)
示例3: search
# 需要导入模块: from forms import SearchForm [as 别名]
# 或者: from forms.SearchForm import validate_on_submit [as 别名]
def search():
form1 = SearchForm()
m = []
entries = {}
message = None
if form1.validate_on_submit():
keywords = form1.query.data
#parse the HTTP response
m = searchWord(keywords)
elif request.form.get("like") != None:
smallURL = request.form.get("small")
bigURL = request.form.get("big")
message = LikeImage(smallURL, bigURL)
return message
elif request.form.get("review") != None:
entries = reviewLiked()
elif request.form.get("dislike") != None:
smallURL = request.form.get("small")
bigURL = request.form.get("big")
dislikeImage(smallURL, bigURL)
entries = reviewLiked()
return render_template('search.html',
title = 'Flickr Search',
form1 = form1,
liked = entries,
imgs = m,
message = message)
示例4: main
# 需要导入模块: from forms import SearchForm [as 别名]
# 或者: from forms.SearchForm import validate_on_submit [as 别名]
def main(key_id=0, act=""):
user_obj = User()
tran_obj = Transaction()
key_obj = Key()
search_form = SearchForm()
keys = user_obj.list_all_key(current_user.role, current_user.company_id)
if request.method == "POST":
if act == "take":
selected_key = key_obj.query.get(key_id)
selected_key.available = False
db.session.add(selected_key)
new_transaction = Transaction(user=current_user, key_id=key_id, time_stamp=datetime.datetime.now() + timedelta(hours=3))
db.session.add(new_transaction)
db.session.commit()
flash("Key Taken")
return redirect(url_for('main'))
elif act == "release":
selected_key = key_obj.query.get(key_id)
selected_key.available = True
db.session.add(selected_key)
db.session.commit()
flash("Key Release")
return redirect(url_for('main'))
if search_form.validate_on_submit():
print search_form.key_input.data
string_input = search_form.key_input.data
if string_input == "":
flash("Please enter something for searching")
return redirect(url_for("main"))
else:
return redirect(url_for('search', input=string_input))
elif request.method == "GET":
return render_template("main.html", keys=keys, search_form=search_form)
示例5: search
# 需要导入模块: from forms import SearchForm [as 别名]
# 或者: from forms.SearchForm import validate_on_submit [as 别名]
def search():
form = SearchForm()
if form.validate_on_submit():
results = wiki.search(form.term.data, form.ignore_case.data)
return render_template('search.html', form=form,
results=results, search=form.term.data)
return render_template('search.html', form=form, search=None)
示例6: book
# 需要导入模块: from forms import SearchForm [as 别名]
# 或者: from forms.SearchForm import validate_on_submit [as 别名]
def book(book_id):
form = SearchForm()
book = Book.query.filter_by(id = book_id).first()
pics = Picture.query.filter_by(book_id = book_id).order_by(Picture.order)
if book == None:
flash('Book not found')
return redirect(url_for('index'))
if form.validate_on_submit():
api = InstagramAPI(client_id=app.config['INSTAGRAM_ID'], client_secret = app.config['INSTAGRAM_SECRET'])
# if max_tag_id > 0:
# if request.args['query']:
# tag_name = request.args['query']
# tag_media, next = api.tag_recent_media(count = 20, max_id = max_tag_id, tag_name = request.args['query'])
# else:
tag_media, next = api.tag_recent_media(count = 20, tag_name = form.query.data)
instagram_results = []
for media in tag_media:
instagram_results.append(media.images['thumbnail'].url)
try:
max_tag_id = next.split('&')[2].split('max_tag_id=')[1]
except:
max_tag_id = None
return render_template('book.html',
query = form.query.data,
instagram_results = tag_media,
pics = pics,
form = form,
next = max_tag_id,
book = book)
return render_template('book.html',
book = book,
pics = pics,
form = form)
示例7: index
# 需要导入模块: from forms import SearchForm [as 别名]
# 或者: from forms.SearchForm import validate_on_submit [as 别名]
def index():
# logic for the edit my profile page
# pull text from input fields and rewrite JSON entry in the DB associated with that profile
form = SearchForm()
if form.validate_on_submit():
# creating dictionary to store text from input text fields
s = {}
for i in ['Profname','about','age','email','phone','loc','empid','school','gradYear','involv', 'picture', 'groupd']:
if request.form[i] != "":
s[i] = request.form[i]
else:
s[i] = ''
s['inter'] = {}
s['username'] = current_user.username
for i in ['exploring', 'nightlife', 'outdoors', 'sports', 'videogames']:
if i in request.form.getlist('interests'):
s['inter'][i] = 1
else:
s['inter'][i] = 0
#converting dictionary to JSON
json_string = json.dumps(s)
#checking if a profile with the username already exists in the db
result = db_connection.execute("""SELECT p.comment_id, p.doc FROM user_profile p WHERE p.doc.username = :x""", x=current_user.username).fetchone()[0]
if result:
this_profile = UserProfile.get(result)
this_profile.doc = json_string
db.session.commit()
else:
db.session.add(UserProfile(json_string))
db.session.commit()
return redirect(url_for('viewprof', username = current_user.username))
return render_template('index.html', form=form)
示例8: search
# 需要导入模块: from forms import SearchForm [as 别名]
# 或者: from forms.SearchForm import validate_on_submit [as 别名]
def search():
form = SearchForm()
if form.validate_on_submit():
longitude, latitude, city = geosearch.get_geo_loc_twice(form.location.data)
results = models.get_venues_by_bounding_box(latitude, longitude)
return render_template('search.html', results=results, form=form)
return render_template('search.html', form=form, results=None)
示例9: social
# 需要导入模块: from forms import SearchForm [as 别名]
# 或者: from forms.SearchForm import validate_on_submit [as 别名]
def social():
friends = dq.find(User, ['nickname'], [g.user.nickname]).first().valid_friends()
form = SearchForm(request.form)
if form.validate_on_submit():
nickname = form.search.data
results = dq.find(User, ['nickname'], [nickname])
count=results.count()
return render_template('social.html', friends=friends, form=form, results=results, results_count=count)
return render_template('social.html', friends=friends, form=form, results=None, results_count=-1)
示例10: search
# 需要导入模块: from forms import SearchForm [as 别名]
# 或者: from forms.SearchForm import validate_on_submit [as 别名]
def search():
form = SearchForm()
if form.validate_on_submit():
# input some search here
search_string = form.search.data
flash(search_string)
app.logger.info(form.search.data)
return redirect(url_for('search_result', query=search_string))
# redirect(url_for('search'))
return render_template('search.html', form=form)
示例11: compsearch
# 需要导入模块: from forms import SearchForm [as 别名]
# 或者: from forms.SearchForm import validate_on_submit [as 别名]
def compsearch():
comps = []
if request.method == 'GET':
return render_template('compsearch.html', comps=comps, search_form=SearchForm())
else:
sf = SearchForm(request.form)
if sf.validate_on_submit():
key = sf.search.data
comps = models.searchComps(key)
return render_template('compsearch.html', comps=comps, search_form=sf)
示例12: search_books
# 需要导入模块: from forms import SearchForm [as 别名]
# 或者: from forms.SearchForm import validate_on_submit [as 别名]
def search_books():
form = SearchForm()
results = None
if request.method == 'POST' and form.validate_on_submit():
book = request.form['book']
author = request.form['author']
results = Book.get_byTitleAuthor(book, author, g.dbs)
# flash('book: %s author: %s' % (books, author))
return render_template('search_books.html', form=form, results=results)
示例13: index
# 需要导入模块: from forms import SearchForm [as 别名]
# 或者: from forms.SearchForm import validate_on_submit [as 别名]
def index():
form = SearchForm()
cordinates = None
if form.validate_on_submit():
query = form.query.data
cordinates = decode_address_to_coordinates(query)
zone_id = find_in_zone(cordinates['lat'], cordinates['lng'])
zone_info = ZoneAssignment.query.filter_by(zone_id=zone_id).all()
return render_template('index.html', form=form, zone_info=zone_info, cordinates=cordinates)
return render_template('index.html', form=form)
示例14: search_results
# 需要导入模块: from forms import SearchForm [as 别名]
# 或者: from forms.SearchForm import validate_on_submit [as 别名]
def search_results(query):
form = SearchForm(request.form)
if request.method == 'POST' and form.validate_on_submit():
return redirect(url_for('search_results', query = form.search.data))
results = Locator.query.whoosh_search(query).\
filter_by(email=current_user.email)
for r in results.order_by(desc(Locator.id)):
print r.id, r.date
return render_template('urls.jade', form=form,
urls=results,
groupnames=get_groupnames())
示例15: main
# 需要导入模块: from forms import SearchForm [as 别名]
# 或者: from forms.SearchForm import validate_on_submit [as 别名]
def main():
if current_user.is_authenticated:
if session['url']:
save_url(session['url'], session['groupname'])
form = SearchForm(request.form)
if request.method == 'POST' and form.validate_on_submit():
return redirect(url_for('search_results',
query = form.search.data))
return render_template('urls.jade', form=form,
urls=get_urls(),
groupnames=get_groupnames())
return render_template('home.jade')