def search(request): """Renders the data search results page 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.GET.get("search", "") if re.match(r"\d{16}", query) or re.match(r"\d{11}", query): url = "http://docquery.fec.gov/cgi-bin/fecimg/?" + query return redirect(url) else: results = api_caller.load_search_results(query) return render( request, "search-results.jinja", { "query": query, "title": "Search results", "results": results }, )
def search(request): """Renders the data search results page 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.GET.get('search', '') 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 render(request, 'search-results.jinja', { 'query': query, 'title': 'Search results', 'results': results })