示例#1
0
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()
示例#2
0
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()