def fetch_most_recent_google_civic_election_id(self): election_manager = ElectionManager() results = election_manager.retrieve_elections_by_date() if results['success']: election_list = results['election_list'] for one_election in election_list: ballot_item_queryset = BallotItem.objects.all() ballot_item_queryset = ballot_item_queryset.filter( google_civic_election_id=one_election.google_civic_election_id) number_found = ballot_item_queryset.count() if positive_value_exists(number_found): # Since we are starting with the most recent election, as soon as we find # any election with ballot items, we can exit. return one_election.google_civic_election_id return 0
def retrieve_most_recent_voter_guide_for_org(self, organization_we_vote_id): status = 'ENTERING_RETRIEVE_MOST_RECENT_VOTER_GUIDE_FOR_ORG' voter_guide_found = False voter_guide = VoterGuide() voter_guide_manager = VoterGuideManager() for time_span in TIME_SPAN_LIST: voter_guide_by_time_span_results = voter_guide_manager.retrieve_voter_guide( vote_smart_time_span=time_span, organization_we_vote_id=organization_we_vote_id) if voter_guide_by_time_span_results['voter_guide_found']: voter_guide_found = True voter_guide = voter_guide_by_time_span_results['voter_guide'] status = 'MOST_RECENT_VOTER_GUIDE_FOUND_FOR_ORG_BY_TIME_SPAN' results = { 'success': voter_guide_found, 'status': status, 'voter_guide_found': voter_guide_found, 'voter_guide': voter_guide, } return results election_manager = ElectionManager() results = election_manager.retrieve_elections_by_date() if results['success']: election_list = results['election_list'] for one_election in election_list: voter_guide_results = voter_guide_manager.retrieve_voter_guide( google_civic_election_id=one_election.google_civic_election_id, organization_we_vote_id=organization_we_vote_id) if voter_guide_results['voter_guide_found']: voter_guide_found = True voter_guide = voter_guide_results['voter_guide'] status = 'MOST_RECENT_VOTER_GUIDE_FOUND_FOR_ORG_BY_ELECTION_ID' results = { 'success': voter_guide_found, 'status': status, 'voter_guide_found': voter_guide_found, 'voter_guide': voter_guide, } return results results = { 'success': False, 'status': status, 'voter_guide_found': voter_guide_found, 'voter_guide': voter_guide, } return results