def getAllDistrictsByID(chamber): # for full senate/house map pages data = [] dist = District.get_by_chamber(chamber) if dist: for d in dist: data.append(d) return data
def addDistrictToParse(dist_id, hpvi): dist = District.get_by_id(dist_id) if dist.count() == 0: data = getDistrictById(dist_id) if data: params = { 'name': data.get('name'), 'chamber': data.get('chamber'), 'lon_delta': data['region']['lon_delta'], 'center_lon': data['region']['center_lon'], 'lat_delta': data['region']['lat_delta'], 'center_lat': data['region']['center_lat'], 'alt_id': data.get('id'), 'dist_id': data.get('boundary_id'), 'bbox': data.get('bbox'), 'shape': data.get('shape'), # add members as parse leg objects 'legislator': data.get('legislator'), 'demographics': data.get('district_demo'), 'leg_elec_results': data.get('leg_results'), 'hpvi': hpvi, } dist = District(**params) dist.save()
def getDistrictById(district_id): # individual district dist = District.get_by_id(district_id) if dist: for d in dist: return d