コード例 #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 search():

    form = SearchForm(request.form)
    if not form.validate():
        groups = Groups.find_usernames_for_group_owners()
        return render_template("index.html",
                               groups=groups,
                               form=SearchForm(),
                               error="Please search for something")

    return redirect(
        url_for("search_results", param=request.form.get("search"), page=1))
コード例 #3
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)
コード例 #4
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)
コード例 #5
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)
コード例 #6
0
def desk_patientdel():
    if 'username' in session and 'AD' in session['username']:
        form=SearchForm(request.form)
        if request.method=='POST':
            if request.form['action'] == 'show':
                con=mysql.connect()
                cursor=con.cursor()
                query = "SELECT * FROM patient WHERE id = %s "
                cursor.execute(query, (form.pid.data,))
                pdata=cursor.fetchall()
                cursor.close()
                con.commit()
                con.close()
                if pdata:
                    return render_template("desk/patient_delete.html",pdata=pdata,form=form,desk_patient_delete_page=True)
                else:
                    flash("Patient not Found")
                    return render_template("desk/patient_delete.html",pdata=pdata,form=form,desk_patient_delete_page=True)
            elif request.form['action'] == 'delete':
                con=mysql.connect()
                cursor=con.cursor()
                query = "DELETE FROM patient WHERE id = %s "
                cursor.execute(query, (form.pid.data,))
                cursor.close()
                con.commit()
                con.close()
                return render_template("desk/patient_delete.html",form=form,desk_patient_delete_page=True)

        else:
            return render_template("desk/patient_delete.html",form=form,desk_patient_delete_page=True)
    else:
        return redirect(url_for('login'))
コード例 #7
0
def userProfile():
    form = SearchForm()
    searchWord = request.args.get('search', "")
    try:
        page = int(request.args.get('page', 1))
        if page < 1: page = 1
    except ValueError:
        page = 1
    if searchWord == "":
        count = Recipe.objects(user__id=current_user.id).count()
    else:
        count = Recipe.objects(
            user__id=current_user.id).search_text(searchWord).count()
    maxPage = count / MAX_RECIPES_PER_PAGE
    if maxPage > 0 and page > maxPage: page = math.ceil(maxPage)
    if searchWord == "":
        recipes = Recipe.objects(user__id=current_user.id).order_by(
            "-id").limit(MAX_RECIPES_PER_PAGE).skip(MAX_RECIPES_PER_PAGE *
                                                    (page - 1))
    else:
        recipes = Recipe.objects(user__id=current_user.id).search_text(
            searchWord).limit(MAX_RECIPES_PER_PAGE).skip(MAX_RECIPES_PER_PAGE *
                                                         (page - 1))
    return render_template('index.html',
                           form=form,
                           searchWord=searchWord,
                           recipes=recipes,
                           count=count,
                           maxPage=maxPage,
                           page=page,
                           recipes_per_page=MAX_RECIPES_PER_PAGE)
コード例 #8
0
def mag_library(mag_items):

    search = SearchForm()
    mag_table = Mag_table(mag_items)
    if mag_items:
        mag_table.border = True

    return render_template("MAG_list.html", table=mag_table, search=search)
コード例 #9
0
def dvd_library(dvd_items):

    search = SearchForm()

    dvd_table = DVD_table(dvd_items)

    if dvd_items:
        dvd_table.border = True

    return render_template("DVD_list.html", table=dvd_table, search=search)
コード例 #10
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)
コード例 #11
0
def index():
    if not current_user.is_authenticated:
        return redirect(url_for('registration'))

    form = SearchForm()
    if request.method == 'POST':
        author = "%"  if form.author.data is None else "%"+form.author.data+"%"
        title = "%" if form.title.data is None else "%"+form.title.data+"%"
        isbn =  "%" if form.isbn.data is None else "%"+form.isbn.data+"%"
        results = db.session.execute("SELECT * FROM books WHERE author LIKE :author AND title LIKE :title AND isbn LIKE :isbn", {"author":author, "title":title, "isbn":isbn})
        return render_template("index.html", form = form, results =         results.fetchall())

    return render_template("index.html", form = form)
コード例 #12
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'))
コード例 #13
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)
コード例 #14
0
ファイル: routes.py プロジェクト: alexnderkong/individual
def homeuser(user_id):
	posts = Posts.query.filter_by(user_id=user_id)
	if current_user.id != user_id:
		return redirect(url_for('home'))
	else:	
		user = Users.query.get_or_404(user_id)
		postData = Posts.query.filter_by(user_id=user_id)

	form = SearchForm()
	if request.method == 'POST' and form.content.data == 'All':
		try:
			print("Alex")
			return redirect(url_for('homeuser', user_id=current_user.id))
		except:
			return "not working"
	elif request.method == 'POST':
		
		try:
			print("Hello")
			postData = Posts.query.filter_by(content=form.content.data, user_id=current_user.id).all()
		except:
			return 'broken'
	return render_template('homeuser.html', title='Homeuser', homeuser=postData ,form=form)
コード例 #15
0
ファイル: routes.py プロジェクト: MAaqibAKhan/Flask_app
def search():
    search = SearchForm()
    form = CountryUpdateForm()
    if request.method == 'POST':
        #if search.validate_on_submit():
        searchData = Country.query.filter_by(countryName=search.search.data)
        print("------SEARCHDATA")
        print(searchData.first())
        print("------")
        print([str(searchData.first())][0][0:5])
        if searchData:
            global searchTerm
            searchTerm.append(str(
                searchData.first()))  #Country.countryName.data
            print("--searchTerm-post-search--")
            print(searchTerm)
            print("---")
            return redirect(url_for('details'))
    else:
        return render_template('search.html',
                               title='Search',
                               search=search,
                               form=form)
コード例 #16
0
def search_patients():
    if 'username' in session and 'PH' in session['username']:
            form = SearchForm(request.form)
            if request.method == 'POST':
                    con=mysql.connect()
                    
                    cursor1=con.cursor()
                    query1 = "SELECT * FROM patient WHERE id = %s "
                    cursor1.execute(query1, (form.pid.data))
                    pdata=cursor1.fetchall()


                    cursor2=con.cursor()
                    query2 = "select medicine_inventory.mname,issued_medicines.quantity_issued,medicine_inventory.rate,medicine_inventory.rate*issued_medicines.quantity_issued from medicine_inventory INNER JOIN issued_medicines ON medicine_inventory.mid = issued_medicines.mid where issued_medicines.pid = %s"
                    cursor2.execute(query2, (form.pid.data,))
                    mdata=cursor2.fetchall()

                    session['pdata']=pdata
                    session['mdata']=mdata
                    session['pid']=form.pid.data


                    cursor1.close()
                    cursor2.close()
                    con.commit()
                    con.close()
                
                    if pdata:
                        return redirect(url_for("display_patient_details"))
                    else:
                        flash("Patient is not registered! Please check ID again!")
                        return render_template("pharmacy/search_patient.html",form=form)
            
            else:
                return render_template("pharmacy/search_patient.html",form=form)
    else:
        return redirect(url_for('login'))
コード例 #17
0
def search_diagnostics():
    if 'username' in session and 'DS' in session['username']:
            form = SearchForm(request.form)
            if request.method == 'POST':
                    con=mysql.connect()
                    
                    cursor1=con.cursor()
                    query1 = "SELECT * FROM patient WHERE id = %s "
                    cursor1.execute(query1, (form.pid.data))
                    pdata=cursor1.fetchall()


                    cursor2=con.cursor()
                    query2 = "select diagnostic_tests.tid,diagnostic_tests.tname,diagnostic_tests.charge FROM diagnostic_tests INNER JOIN diagnostic_tests_conducted ON diagnostic_tests.tid = diagnostic_tests_conducted.tid where diagnostic_tests_conducted.pid = %s"
                    cursor2.execute(query2, (form.pid.data))
                    ddata=cursor2.fetchall()

                    session['pdata']=pdata
                    session['ddata']=ddata
                    session['pid']=form.pid.data


                    cursor1.close()
                    cursor2.close()
                    con.commit()
                    con.close()
                
                    if pdata:
                        return redirect(url_for("display_diagnostic_details"))
                    else:
                        flash("Patient is not registered! Please check ID again!")
                        return render_template("diagnostic/search_diagnostics.html",form=form)
            
            else:
                return render_template("diagnostic/search_diagnostics.html",form=form)
    else:
        return redirect(url_for('login'))
コード例 #18
0
def index():
    groups = Groups.find_usernames_for_group_owners()

    return render_template("index.html", groups=groups, form=SearchForm())
コード例 #19
0
def select_users(query):
	
	SelectUsersForm = select_users_form_factory(query)
	select_users_form = SelectUsersForm()

	if(select_users_form.validate_on_submit()):
		selected_users = select_users_form.users.data
	
		if(current_user in selected_users):
			flash("You Cannot choose your yourself!", 'error')
			return render_template('search_results.html', title = 'Search', select_form = select_users_form, search_form = SearchForm(search = query), selected = SelectedUser.query.all())
		
		for user in selected_users:
			
			existing_user = SelectedUser.query.filter_by(username = user.username).first()			
			if (existing_user is not None):
				flash("You have already selected user {}".format(user.username), 'error')
				return render_template('search_results.html', title = 'Search', select_form = select_users_form, search_form = SearchForm(search = query), selected = SelectedUser.query.all())
			
			else:
				u = SelectedUser(username = user.username)
				db.session.add(u)
				db.session.commit()

		return redirect(url_for('search_users'))

	return render_template('search_results.html', title = 'Search', select_form = select_users_form, search_form = SearchForm(search = query), selected = SelectedUser.query.all())
コード例 #20
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())
コード例 #21
0
def home():
    form = SearchForm()
    ids = tuple([random.randint(1, 5000) for _ in range(10)])
    result = db.execute("SELECT * FROM books WHERE books.id IN :ids",
                        {"ids": ids})
    return render_template("home.html", form=form, result=result)
コード例 #22
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)