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)
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))
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)
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)
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)
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'))
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)
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)
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)
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)
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)
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'))
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)
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)
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)
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'))
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'))
def index(): groups = Groups.find_usernames_for_group_owners() return render_template("index.html", groups=groups, form=SearchForm())
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())
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())
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)
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)