def addLegislatorToParse(leg_id): leg=Legislator.get_by_id(leg_id) if leg.count()==0: data=getMNLegislatorById(leg_id) if data: first,last=data.get('first_name'),data.get('last_name') name=first+' '+last params={'name': name, 'full_name': data.get('full_name'), 'chamber': data.get('chamber'), 'party': data.get('party'), 'district': data.get('district'), 'office_phone': data.get('office_phone'), 'leg_id': data.get('leg_id'), 'votesmart_id': data.get('votesmart_id'), 'leg_url': data.get('+leg_url'), 'active': data.get('active'), 'transparencydata_id': data.get('transparencydata_id'), 'photo_url': data.get('photo_url'), 'roles': data.get('roles'), 'old_roles': data.get('old_roles'), 'offices': data.get('offices'), } leg=Legislator(**params) leg.save()
def addLegislatorsToParseCommittee(com_id): com=Committee.get_by_id(com_id) if com.count()==1: for c in com: members=[] for m in c.members: leg=Legislator.get_by_id(m.get('leg_id')) members.append(leg) c.members=members c.save()