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


Python SearchForm.validate_on_submit方法代码示例

本文整理汇总了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)
开发者ID:pstraus,项目名称:hrc-ee,代码行数:33,代码来源:app.py

示例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)
开发者ID:urschrei,项目名称:CDP,代码行数:9,代码来源:views.py

示例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)
开发者ID:charliezhangqian,项目名称:Flickr_Feeds,代码行数:32,代码来源:views.py

示例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)
开发者ID:nnduc1994,项目名称:Aurio,代码行数:35,代码来源:views.py

示例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)
开发者ID:Tutt-Library,项目名称:wiki,代码行数:9,代码来源:app.py

示例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)
开发者ID:danlopez,项目名称:weddstagram,代码行数:37,代码来源:views.py

示例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)
开发者ID:ImNitinNayar7,项目名称:json-in-db,代码行数:34,代码来源:views.py

示例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)
开发者ID:lvgelder,项目名称:gu-venues,代码行数:9,代码来源:views.py

示例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)
开发者ID:Tiotao,项目名称:Yikes,代码行数:11,代码来源:views.py

示例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)
开发者ID:huangjien,项目名称:autoP,代码行数:12,代码来源:views.py

示例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)        
开发者ID:adlnet,项目名称:xci,代码行数:12,代码来源:views.py

示例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)
开发者ID:gunkow,项目名称:test_library,代码行数:12,代码来源:views.py

示例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)
开发者ID:juzten,项目名称:cpd-zones,代码行数:13,代码来源:app.py

示例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())
开发者ID:samitnuk,项目名称:urlsaver,代码行数:13,代码来源:views.py

示例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')
开发者ID:samitnuk,项目名称:urlsaver,代码行数:14,代码来源:views.py


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