code: def activate_legislators(current_term, abbr):
      
      for legislator in db.legislators.find(
          {'roles': {'$elemMatch':
                     {settings.LEVEL_FIELD: abbr, 'term': current_term}}}):
          active_role = legislator['roles'][0]
  
          if not active_role.get('end_date') and active_role['type'] == 'member':
              legislator['active'] = True
              legislator['party'] = active_role.get('party', None)
              legislator['district'] = active_role.get('district', None)
              legislator['chamber'] = active_role.get('chamber', None)
  
          legislator['updated_at'] = datetime.datetime.utcnow()
          db.legislators.save(legislator, safe=True)
docs: Sets the 'active' flag on legislators and populates top-level
      district/chamber/party fields for currently serving legislators.