def searchDisplay(keyword): form = SearchForm() data = Search(keyword) if form.validate_on_submit(): keyword = form.search.data return redirect(url_for('searchDisplay', keyword=keyword)) return render_template('searchDisplay.html', title='Search Result', data=data, form=form, keyword=keyword)
def addFavoriteSearch(keyword, service_name, service_id): form = SearchForm() data = Search(keyword) email = current_user.email result = updateFavorite(email, service_name, service_id) if result == 'success': flash('You have add one favorite successfully!', 'success') else: flash('You have already favorited this service.', 'info') if form.validate_on_submit(): keyword = form.search.data return redirect(url_for('searchDisplay', keyword=keyword)) return render_template('searchDisplay.html', title='Search Result', keyword=keyword, data=data, form=form)
def addFavoriteSearch(keyword, service_name, service_id): form = SearchForm() if keyword == 'hotline' or keyword == 'hotlines': data = getServices('hotlines') else: data = Search(keyword) total = len(data) if total != 0: map = ifMap(data) else: map = 'no' page, per_page, offset = get_page_args(page_parameter='page', per_page_parameter='per_page') pagination_data = searchPage(data, offset=offset, per_page=per_page) pagination = Pagination(page=page, per_page=per_page, total=total, css_framework='bootstrap4') email = current_user.email result = updateFavorite(email, service_name, service_id) if result == 'success': flash('You have add one favorite successfully!', 'success') if current_user.is_authenticated: email = current_user.email favoList = getFavorite(email) else: favoList = [] if form.validate_on_submit(): keyword = form.search.data return redirect(url_for('searchDisplay', keyword=keyword)) return render_template('searchDisplay.html', title='Search Result', keyword=keyword, form=form, favoList=favoList, pagination_data=pagination_data, page=page, per_page=per_page, pagination=pagination, map=map)
def home(): form = SearchForm() if form.validate_on_submit(): keyword = form.search.data return redirect(url_for('searchDisplay', keyword=keyword)) return render_template('home.html', title='UmbSupport_Home', form=form)