def search(): """Renders the top-level /data page. If there's a query string, it will load candidate and committee search results. If the string is a 16 or 11 digit number then it will redirect to the page-by-page viewer. If there's no query, then we'll load the main landing page with all the necessary data. """ query = request.args.get('search') if query: if re.match('\d{16}', query) or re.match('\d{11}', query): url = 'http://docquery.fec.gov/cgi-bin/fecimg/?' + query return redirect(url) else: results = api_caller.load_search_results(query) return views.render_search_results(results, query) else: top_candidates_raising = api_caller.load_top_candidates('-receipts', per_page=3) return render_template('landing.html', page='home', parent='data', dates=utils.date_ranges(), top_candidates_raising=top_candidates_raising['results'] if top_candidates_raising else None, first_of_year=datetime.date(datetime.date.today().year, 1, 1).strftime('%m/%d/%Y'), last_of_year=datetime.date(datetime.date.today().year, 12, 31).strftime('%m/%d/%Y'), title='Campaign finance data')
def search(): query = request.args.get('search') if query: result_type = request.args.get('search_type') or 'candidates' results = api_caller.load_search_results(query, result_type) return views.render_search_results(results, query, result_type) else: return render_template('search.html', page='home', dates=utils.date_ranges(), title='Campaign finance data')
def search(): query = request.args.get("search") if query: result_type = request.args.get("search_type") or "candidates" results = load_search_results(query, result_type) return views.render_search_results(results, query, result_type) else: return render_template("search.html", page="home", dates=utils.date_ranges())
def search(): query = request.args.get('search') if query: result_type = request.args.get('search_type') or 'candidates' results = api_caller.load_search_results(query, result_type) return views.render_search_results(results, query, result_type) else: return render_template('landing.html', page='home', parent='data', dates=utils.date_ranges(), top_candidates_raising = api_caller.load_top_candidates('-receipts')['results'], top_candidates_spending = api_caller.load_top_candidates('-disbursements')['results'], top_pacs_raising = api_caller.load_top_pacs('-receipts')['results'], top_pacs_spending = api_caller.load_top_pacs('-disbursements')['results'], top_parties_raising = api_caller.load_top_parties('-receipts')['results'], top_parties_spending = api_caller.load_top_parties('-disbursements')['results'], title='Campaign finance data')
def search(): """Renders the top-level /data page. If there's a query string, it will load candidate and committee search results. If the string is a 16 or 11 digit number then it will redirect to the page-by-page viewer. If there's no query, then we'll load the main landing page with all the necessary data. """ query = request.args.get('search') if query: if re.match('\d{16}', query) or re.match('\d{11}', query): url = 'http://docquery.fec.gov/cgi-bin/fecimg/?' + query return redirect(url) else: results = api_caller.load_search_results(query) return views.render_search_results(results, query) else: top_candidates_raising = api_caller.load_top_candidates('-receipts', per_page=3) return render_template( 'landing.html', page='home', parent='data', dates=utils.date_ranges(), top_candidates_raising=top_candidates_raising['results'] if top_candidates_raising else None, first_of_year=datetime.date(datetime.date.today().year, 1, 1).strftime('%m/%d/%Y'), last_of_year=datetime.date(datetime.date.today().year, 12, 31).strftime('%m/%d/%Y'), title='Campaign finance data')
def search(): query = request.args.get('search') if query: return render_search_results(load_search_results(query), query) else: return render_template('search.html');
def search(): query = request.args.get('search') if query: return render_search_results(load_search_results(query), query) else: return render_template('search.html')