def individual_entity(request, entity_id): cycle, standardized_name, metadata, context = prepare_entity_view(request, entity_id, 'individual') if metadata['contributions']: amount = int(float(metadata['entity_info']['totals']['contributor_amount'])) context['sections']['contributions'] = \ indiv_contribution_section(entity_id, standardized_name, cycle, amount, metadata['entity_info']['external_ids']) if metadata['lobbying']: context['sections']['lobbying'] = \ indiv_lobbying_section(entity_id, standardized_name, cycle, metadata['entity_info']['external_ids']) return render_to_response('individual.html', context, entity_context(request, cycle, metadata['available_cycles']))
def politician_entity(request, entity_id): cycle, standardized_name, metadata, context = prepare_entity_view(request, entity_id, 'politician') if cycle == DEFAULT_CYCLE: """ This section is to make sure we always display the most recently held seat, even if the candidate did not hold an office in the most recent cycle(s) """ # get just the metadata that is the by cycle stuff cycle_info = [ (k,v) for k,v in metadata['entity_info']['metadata'].items() if k.isdigit() ] # this district_held check is a temporary hack # until we do a full contribution data reload sorted_cycles = sorted(cycle_info, key=lambda x: x[0] if x[1]['district_held'].strip() != '-' else 0) max_year_with_seat_held = sorted_cycles[-1][0] metadata['entity_info']['metadata']['seat_held'] = metadata['entity_info']['metadata'][max_year_with_seat_held]['seat_held'] metadata['entity_info']['metadata']['district_held'] = metadata['entity_info']['metadata'][max_year_with_seat_held]['district_held'] metadata['entity_info']['metadata']['state_held'] = metadata['entity_info']['metadata'][max_year_with_seat_held]['state_held'] # make a shorter-named copy meta = metadata['entity_info']['metadata'] # check that seat_held is properly defined and zero it out if not seat_held = meta['seat_held'] if meta['district_held'].strip() != '-' else '' metadata['entity_info']['metadata']['seat_held'] = seat_held metadata['entity_info']['name_with_meta'] = str(standardized_name.plus_metadata(meta.get('party'), meta.get('state'))) if metadata['contributions']: amount = int(float(metadata['entity_info']['totals']['recipient_amount'])) context['sections']['contributions'] = \ pol_contribution_section(entity_id, standardized_name, cycle, amount, metadata['entity_info']['external_ids']) if metadata['earmarks']: context['sections']['earmarks'] = \ pol_earmarks_section(entity_id, standardized_name, cycle, metadata['entity_info']['external_ids']) return render_to_response('politician.html', context, entity_context(request, cycle, metadata['available_cycles']))
def org_industry_entity(request, entity_id, type): cycle, standardized_name, metadata, context = prepare_entity_view(request, entity_id, type) if metadata['contributions']: amount = int(float(metadata['entity_info']['totals']['contributor_amount'])) context['sections']['contributions'] = \ org_contribution_section(entity_id, standardized_name, cycle, amount, type, metadata['entity_info']['external_ids']) if metadata['lobbying']: is_lobbying_firm = bool(metadata['entity_info']['metadata'].get('lobbying_firm', False)) context['sections']['lobbying'] = \ org_lobbying_section(entity_id, standardized_name, cycle, type, metadata['entity_info']['external_ids'], is_lobbying_firm) if 'regulations' in metadata and metadata['regulations']: context['sections']['regulations'] = \ org_regulations_section(entity_id, standardized_name, cycle, metadata['entity_info']['external_ids']) if 'earmarks' in metadata and metadata['earmarks']: context['sections']['earmarks'] = \ org_earmarks_section(entity_id, standardized_name, cycle, metadata['entity_info']['external_ids']) if metadata['fed_spending']: context['sections']['federal_spending'] = \ org_spending_section(entity_id, standardized_name, cycle, metadata['entity_info']['totals']) if 'contractor_misconduct' in metadata and metadata['contractor_misconduct']: context['sections']['contractor_misconduct'] = \ org_contractor_misconduct_section(entity_id, standardized_name, cycle, metadata['entity_info']['external_ids']) if 'epa_echo' in metadata and metadata['epa_echo']: context['sections']['epa_echo'] = \ org_epa_echo_section(entity_id, standardized_name, cycle, metadata['entity_info']['external_ids'], metadata['entity_info']['totals']) if 'faca' in metadata and metadata['faca']: context['sections']['faca'] = org_faca_section(entity_id, standardized_name, cycle) return render_to_response('%s.html' % type, context, entity_context(request, cycle, metadata['available_cycles']))