def spending(request): top_category = request.GET.get('top_category', 'P') cycle = request.GET.get('cycle', constants.DEFAULT_TIME_PERIOD) if top_category in ['pac']: top_spenders = api_caller.load_top_pacs('-disbursements', cycle=cycle, per_page=10) elif top_category in ['party']: top_spenders = api_caller.load_top_parties('-disbursements', cycle=cycle, per_page=10) else: top_spenders = api_caller.load_top_candidates('-disbursements', office=top_category, cycle=cycle, per_page=10) if cycle == datetime.datetime.today().year: coverage_end_date = datetime.datetime.today() else: coverage_end_date = datetime.date(cycle, 12, 31) return render( request, 'spending-breakdown.jinja', { 'parent': 'data', 'title': 'Spending breakdown', 'top_category': top_category, 'coverage_start_date': datetime.date(cycle - 1, 1, 1), 'coverage_end_date': coverage_end_date, 'cycle': cycle, 'top_spenders': top_spenders['results'], 'page_info': utils.page_info(top_spenders['pagination']) })
def landing(request): top_candidates_raising = api_caller.load_top_candidates("-receipts", per_page=3) return render( request, "landing.jinja", { "parent": "data", "title": "Campaign finance data", "dates": utils.date_ranges(), "top_candidates_raising": top_candidates_raising["results"] if top_candidates_raising else None, "first_of_year": date(date.today().year, 1, 1).strftime("%m/%d/%Y"), "last_of_year": date(date.today().year, 12, 31).strftime("%m/%d/%Y"), "social_image_identifier": "data", }, )
def landing(request): top_candidates_raising = api_caller.load_top_candidates('-receipts', per_page=3) return render(request, 'landing.jinja', { 'title': 'Campaign finance 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'), })