コード例 #1
0
ファイル: views.py プロジェクト: digital-land/cpos-prototype
def search():
    form = SearchForm()
    if form.validate_on_submit():
        headers = {'User-Agent': current_app.config['S3_USER_AGENT'], 'Content-Type': 'application/json'}
        url = current_app.config["SEARCH_URL"]
        result = get_search_result(url, form.query.data, headers)
        return render_template('search.html', form=SearchForm(), result=result)
    return render_template('search.html', form=form)
コード例 #2
0
def translation():
    '''Translate ES => EN or EN => ES'''

    form = SearchForm()
    if form.validate_on_submit():
        if current_user.is_anonymous:
            flash('Please sign in to translate words.', 'warning')
            return redirect(url_for('main.translation'))
        else:
            query_api(form.word.data)
            return
    return render_template('main/translation.html', form=form)
コード例 #3
0
def search():
    """ Serach informations about a book"""
    ## get information form the form and query database then rander the page with the result
    form = SearchForm()
    if form.validate_on_submit():
        search = form.search.data
        result = db.execute(
            "SELECT * FROM books WHERE isbn  LIKE :search OR author LIKE :search OR title LIKE :search",
            {
                "search": "%" + search + "%"
            }).fetchall()
        return render_template('search.html', result=result, form=form)
    return render_template('index.html', form=form)
コード例 #4
0
ファイル: base.py プロジェクト: numkem/pycollect-web
def search():
    form = SearchForm()

    if form.validate_on_submit():
        # Get games from current database
        api_games = search_items(form.query.data.split(' '))

        # Get games from API
        db_games = mongo.db.games.find({'$text': {'$search': form.query.data}})
        search_results = merge_results(list(db_games), api_games)
        return render_template('search.html',
                               form=form,
                               results=search_results)
    return render_template('search.html', form=form, results=None)
コード例 #5
0
def music():
    form = SearchForm()
    uploads = Upload.query.all()

    if form.validate_on_submit():
        search_data = "%s" % (form.search.data)
        results = Upload.query.filter(
            Upload.title.like("%" + search_data + "%")).all()
        form = SearchForm()

        return render_template('music.html',
                               title="Your Search Results",
                               form=form,
                               results=results,
                               uploads=uploads)

    return render_template('music.html',
                           title='Music',
                           uploads=uploads,
                           form=form)
コード例 #6
0
ファイル: routes.py プロジェクト: santhosh-reddy03/hms
def search_patient():
    if 'user_id' in session and session['user_type'] == 'E':
        # code here
        form = SearchForm()
        if form.validate_on_submit():
            sql = text(
                "SELECT  patient_ssn FROM patients WHERE patient_id = :x AND status = :state"
            )
            rslt = db.engine.execute(sql,
                                     x=form.patient_id.data,
                                     state='ACTIVE')
            name = [row[0] for row in rslt]
            if len(name) == 0:
                flash('Patient not found !', 'warning')
                return redirect(url_for('search_patient'))
            else:
                set_details(form, ssn_flag=False)  # ssn is kept as changeable
        return render_template('search_patient.html',
                               form=form,
                               title='Search Patient Details')
    else:
        flash('You are not logged in ', 'danger')
        return redirect(url_for('login'))
コード例 #7
0
def books():
    form = SearchForm()
    result_images = []

    if form.validate_on_submit():
        quest = form.search.data
        if quest != None:
            quest = quest.strip().replace("'", "")
            result_books = db.execute(
                "SELECT * from books where isbn LIKE ('%" + quest +
                "%')  or lower(title) LIKE lower('%" + quest +
                "%') or  lower(author) LIKE lower('%" + quest +
                "%') order by year desc;").fetchall()
            result_count = len(result_books)

            #image_link = ""
            for i in range(len(result_books)):
                image_link = get_google_books_data(result_books[i].isbn)[3]
                result_images.append(image_link)

            if result_count == 0:
                return render_template('books.html',
                                       form=form,
                                       title='404',
                                       quest=quest,
                                       result_count=result_count,
                                       message="404 Not Found"), 404

            return render_template('books.html',
                                   form=form,
                                   title='Search Results',
                                   quest=quest,
                                   result_count=result_count,
                                   result_books=result_books,
                                   result_images=result_images)
    return render_template('books.html', form=form)
コード例 #8
0
def search_users():
	search_form = SearchForm()
	if(search_form.validate_on_submit()):
		return redirect(url_for('select_users', query = search_form.search.data))		

	return render_template('search.html', title = 'Search', search_form = search_form, selected = SelectedUser.query.all())
コード例 #9
0
def search():
    form = SearchForm()
    if form.validate_on_submit() and request.method == 'POST':
        quest = form.search.data
        return books(quest)
    return render_template('search.html', title="Search", form=form)