本文整理汇总了Python中wevote_functions.functions.convert_to_int函数的典型用法代码示例。如果您正苦于以下问题:Python convert_to_int函数的具体用法?Python convert_to_int怎么用?Python convert_to_int使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了convert_to_int函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: organization_edit_existing_position_form_view
def organization_edit_existing_position_form_view(request, organization_id, position_id):
"""
In edit, you can only change your stance and comments, not who or what the position is about
:param request:
:param organization_id:
:param position_id:
:return:
"""
authority_required = {'verified_volunteer'} # admin, verified_volunteer
if not voter_has_authority(request, authority_required):
return redirect_to_sign_in_page(request, authority_required)
messages_on_stage = get_messages(request)
organization_id = convert_to_int(organization_id)
position_id = convert_to_int(position_id)
organization_on_stage_found = False
try:
organization_on_stage = Organization.objects.get(id=organization_id)
organization_on_stage_found = True
except Organization.MultipleObjectsReturned as e:
handle_record_found_more_than_one_exception(e, logger=logger)
except Organization.DoesNotExist:
# This is fine, create new
pass
if not organization_on_stage_found:
messages.add_message(request, messages.INFO,
'Could not find organization when trying to edit a position.')
return HttpResponseRedirect(reverse('organization:organization_position_list', args=([organization_id])))
# Get the existing position
organization_position_on_stage = PositionEntered()
organization_position_on_stage_found = False
position_entered_manager = PositionEnteredManager()
results = position_entered_manager.retrieve_position_from_id(position_id)
if results['position_found']:
organization_position_on_stage_found = True
organization_position_on_stage = results['position']
if not organization_position_on_stage_found:
messages.add_message(request, messages.INFO,
'Could not find organization position when trying to edit.')
return HttpResponseRedirect(reverse('organization:organization_position_list', args=([organization_id])))
# Note: We have access to the candidate campaign through organization_position_on_stage.candidate_campaign
election_list = Election.objects.all()
if organization_position_on_stage_found:
template_values = {
'is_in_edit_mode': True,
'messages_on_stage': messages_on_stage,
'organization': organization_on_stage,
'organization_position': organization_position_on_stage,
'possible_stances_list': ORGANIZATION_STANCE_CHOICES,
'stance_selected': organization_position_on_stage.stance,
'election_list': election_list,
}
return render(request, 'organization/organization_position_edit.html', template_values)
示例2: measure_summary_view
def measure_summary_view(request, measure_id):
authority_required = {'verified_volunteer'} # admin, verified_volunteer
if not voter_has_authority(request, authority_required):
return redirect_to_sign_in_page(request, authority_required)
messages_on_stage = get_messages(request)
measure_id = convert_to_int(measure_id)
measure_on_stage_found = False
measure_on_stage = ContestMeasure()
google_civic_election_id = convert_to_int(request.GET.get('google_civic_election_id', 0))
try:
measure_on_stage = ContestMeasure.objects.get(id=measure_id)
measure_on_stage_found = True
except ContestMeasure.MultipleObjectsReturned as e:
handle_record_found_more_than_one_exception(e, logger=logger)
except ContestMeasure.DoesNotExist:
# This is fine, create new
pass
election_list = Election.objects.order_by('-election_day_text')
if measure_on_stage_found:
template_values = {
'messages_on_stage': messages_on_stage,
'measure': measure_on_stage,
'election_list': election_list,
'google_civic_election_id': google_civic_election_id,
}
else:
template_values = {
'messages_on_stage': messages_on_stage,
}
return render(request, 'measure/measure_summary.html', template_values)
示例3: retrieve_vote_smart_candidate
def retrieve_vote_smart_candidate(
self, vote_smart_candidate_id=None, first_name=None, last_name=None, state_code=None):
"""
We want to return one and only one candidate
:param vote_smart_candidate_id:
:param first_name:
:param last_name:
:param state_code:
:return:
"""
error_result = False
exception_does_not_exist = False
exception_multiple_object_returned = False
vote_smart_candidate = VoteSmartCandidate()
try:
if positive_value_exists(vote_smart_candidate_id):
vote_smart_candidate = VoteSmartCandidate.objects.get(candidateId=vote_smart_candidate_id)
vote_smart_candidate_id = convert_to_int(vote_smart_candidate.candidateId)
status = "RETRIEVE_VOTE_SMART_CANDIDATE_FOUND_BY_ID"
elif positive_value_exists(first_name) or positive_value_exists(last_name):
candidate_queryset = VoteSmartCandidate.objects.all()
if positive_value_exists(first_name):
first_name = first_name.replace("`", "'") # Vote Smart doesn't like this kind of apostrophe: `
candidate_queryset = candidate_queryset.filter(Q(firstName__istartswith=first_name) |
Q(nickName__istartswith=first_name) |
Q(preferredName__istartswith=first_name))
if positive_value_exists(last_name):
last_name = last_name.replace("`", "'") # Vote Smart doesn't like this kind of apostrophe: `
candidate_queryset = candidate_queryset.filter(lastName__iexact=last_name)
if positive_value_exists(state_code):
candidate_queryset = candidate_queryset.filter(Q(electionStateId__iexact=state_code) |
Q(electionStateId__iexact="NA"))
vote_smart_candidate_list = list(candidate_queryset[:1])
if vote_smart_candidate_list:
vote_smart_candidate = vote_smart_candidate_list[0]
else:
vote_smart_candidate = VoteSmartCandidate()
vote_smart_candidate_id = convert_to_int(vote_smart_candidate.candidateId)
status = "RETRIEVE_VOTE_SMART_CANDIDATE_FOUND_BY_NAME"
else:
status = "RETRIEVE_VOTE_SMART_CANDIDATE_SEARCH_INDEX_MISSING"
except VoteSmartCandidate.MultipleObjectsReturned as e:
exception_multiple_object_returned = True
status = "RETRIEVE_VOTE_SMART_CANDIDATE_MULTIPLE_OBJECTS_RETURNED"
except VoteSmartCandidate.DoesNotExist:
exception_does_not_exist = True
status = "RETRIEVE_VOTE_SMART_CANDIDATE_NOT_FOUND"
results = {
'success': True if positive_value_exists(vote_smart_candidate_id) else False,
'status': status,
'error_result': error_result,
'DoesNotExist': exception_does_not_exist,
'MultipleObjectsReturned': exception_multiple_object_returned,
'vote_smart_candidate_found': True if positive_value_exists(vote_smart_candidate_id) else False,
'vote_smart_candidate_id': vote_smart_candidate_id,
'vote_smart_candidate': vote_smart_candidate,
}
return results
示例4: candidate_politician_match_view
def candidate_politician_match_view(request):
authority_required = {'verified_volunteer'} # admin, verified_volunteer
if not voter_has_authority(request, authority_required):
return redirect_to_sign_in_page(request, authority_required)
candidate_id = request.GET.get('candidate_id', 0)
candidate_id = convert_to_int(candidate_id)
# google_civic_election_id is included for interface usability reasons and isn't used in the processing
google_civic_election_id = request.GET.get('google_civic_election_id', 0)
google_civic_election_id = convert_to_int(google_civic_election_id)
if not positive_value_exists(candidate_id):
messages.add_message(request, messages.ERROR, "The candidate_id variable was not passed in.")
return HttpResponseRedirect(reverse('candidate:candidate_edit', args=(candidate_id,)))
candidate_campaign_manager = CandidateCampaignManager()
results = candidate_campaign_manager.retrieve_candidate_campaign_from_id(candidate_id)
if not positive_value_exists(results['candidate_campaign_found']):
messages.add_message(request, messages.ERROR,
"Candidate '{candidate_id}' not found.".format(candidate_id=candidate_id))
return HttpResponseRedirect(reverse('candidate:candidate_edit', args=(candidate_id,)))
we_vote_candidate = results['candidate_campaign']
# Make sure we have a politician for this candidate. If we don't, create a politician entry, and save the
# politician_we_vote_id in the candidate
results = candidate_politician_match(we_vote_candidate)
display_messages = True
if results['status'] and display_messages:
messages.add_message(request, messages.INFO, results['status'])
return HttpResponseRedirect(reverse('candidate:candidate_edit', args=(candidate_id,)) +
"?google_civic_election_id=" + str(google_civic_election_id))
示例5: retrieve_candidate_campaign
def retrieve_candidate_campaign(
self, candidate_campaign_id, candidate_campaign_we_vote_id=None, candidate_maplight_id=None,
candidate_name=None, candidate_vote_smart_id=None):
error_result = False
exception_does_not_exist = False
exception_multiple_object_returned = False
candidate_campaign_on_stage = CandidateCampaign()
try:
if positive_value_exists(candidate_campaign_id):
candidate_campaign_on_stage = CandidateCampaign.objects.get(id=candidate_campaign_id)
candidate_campaign_id = candidate_campaign_on_stage.id
candidate_campaign_we_vote_id = candidate_campaign_on_stage.we_vote_id
status = "RETRIEVE_CANDIDATE_FOUND_BY_ID"
elif positive_value_exists(candidate_campaign_we_vote_id):
candidate_campaign_on_stage = CandidateCampaign.objects.get(we_vote_id=candidate_campaign_we_vote_id)
candidate_campaign_id = candidate_campaign_on_stage.id
candidate_campaign_we_vote_id = candidate_campaign_on_stage.we_vote_id
status = "RETRIEVE_CANDIDATE_FOUND_BY_WE_VOTE_ID"
elif positive_value_exists(candidate_maplight_id):
candidate_campaign_on_stage = CandidateCampaign.objects.get(maplight_id=candidate_maplight_id)
candidate_campaign_id = candidate_campaign_on_stage.id
candidate_campaign_we_vote_id = candidate_campaign_on_stage.we_vote_id
status = "RETRIEVE_CANDIDATE_FOUND_BY_MAPLIGHT_ID"
elif positive_value_exists(candidate_vote_smart_id):
candidate_campaign_on_stage = CandidateCampaign.objects.get(vote_smart_id=candidate_vote_smart_id)
candidate_campaign_id = candidate_campaign_on_stage.id
candidate_campaign_we_vote_id = candidate_campaign_on_stage.we_vote_id
status = "RETRIEVE_CANDIDATE_FOUND_BY_VOTE_SMART_ID"
elif positive_value_exists(candidate_name):
candidate_campaign_on_stage = CandidateCampaign.objects.get(candidate_name=candidate_name)
candidate_campaign_id = candidate_campaign_on_stage.id
candidate_campaign_we_vote_id = candidate_campaign_on_stage.we_vote_id
status = "RETRIEVE_CANDIDATE_FOUND_BY_NAME"
else:
status = "RETRIEVE_CANDIDATE_SEARCH_INDEX_MISSING"
except CandidateCampaign.MultipleObjectsReturned as e:
handle_record_found_more_than_one_exception(e, logger=logger)
exception_multiple_object_returned = True
status = "RETRIEVE_CANDIDATE_MULTIPLE_OBJECTS_RETURNED"
except CandidateCampaign.DoesNotExist:
exception_does_not_exist = True
status = "RETRIEVE_CANDIDATE_NOT_FOUND"
results = {
'success': True if convert_to_int(candidate_campaign_id) > 0 else False,
'status': status,
'error_result': error_result,
'DoesNotExist': exception_does_not_exist,
'MultipleObjectsReturned': exception_multiple_object_returned,
'candidate_campaign_found': True if convert_to_int(candidate_campaign_id) else False,
'candidate_campaign_id': convert_to_int(candidate_campaign_id),
'candidate_campaign_we_vote_id': candidate_campaign_we_vote_id,
'candidate_campaign': candidate_campaign_on_stage,
}
return results
示例6: retrieve_vote_smart_official
def retrieve_vote_smart_official(
self, vote_smart_candidate_id=None, first_name=None, last_name=None, state_code=None):
"""
We want to return one and only one official
:param vote_smart_candidate_id:
:param first_name:
:param last_name:
:param state_code:
:return:
"""
error_result = False
exception_does_not_exist = False
exception_multiple_object_returned = False
vote_smart_official = VoteSmartOfficial()
try:
if positive_value_exists(vote_smart_candidate_id):
vote_smart_official = VoteSmartOfficial.objects.get(candidateId=vote_smart_candidate_id)
vote_smart_candidate_id = convert_to_int(vote_smart_official.candidateId)
status = "RETRIEVE_VOTE_SMART_OFFICIAL_FOUND_BY_ID"
elif positive_value_exists(first_name) or positive_value_exists(last_name):
official_queryset = VoteSmartOfficial.objects.all()
if positive_value_exists(first_name):
official_queryset = official_queryset.filter(firstName__istartswith=first_name)
if positive_value_exists(last_name):
official_queryset = official_queryset.filter(lastName__iexact=last_name)
if positive_value_exists(state_code):
official_queryset = official_queryset.filter(officeStateId__iexact=state_code)
vote_smart_official_list = list(official_queryset[:1])
if vote_smart_official_list:
vote_smart_official = vote_smart_official_list[0]
else:
vote_smart_official = VoteSmartOfficial()
vote_smart_candidate_id = convert_to_int(vote_smart_official.candidateId)
status = "RETRIEVE_VOTE_SMART_OFFICIAL_FOUND_BY_NAME"
else:
status = "RETRIEVE_VOTE_SMART_OFFICIAL_SEARCH_INDEX_MISSING"
except VoteSmartOfficial.MultipleObjectsReturned as e:
exception_multiple_object_returned = True
status = "RETRIEVE_VOTE_SMART_OFFICIAL_MULTIPLE_OBJECTS_RETURNED"
except VoteSmartOfficial.DoesNotExist:
exception_does_not_exist = True
status = "RETRIEVE_VOTE_SMART_OFFICIAL_NOT_FOUND"
results = {
'success': True if positive_value_exists(vote_smart_candidate_id) else False,
'status': status,
'error_result': error_result,
'DoesNotExist': exception_does_not_exist,
'MultipleObjectsReturned': exception_multiple_object_returned,
'vote_smart_official_found': True if positive_value_exists(vote_smart_candidate_id) else False,
'vote_smart_candidate_id': vote_smart_candidate_id,
'vote_smart_official': vote_smart_official,
}
return results
示例7: organization_position_list_view
def organization_position_list_view(request, organization_id):
authority_required = {'verified_volunteer'} # admin, verified_volunteer
if not voter_has_authority(request, authority_required):
return redirect_to_sign_in_page(request, authority_required)
messages_on_stage = get_messages(request)
organization_id = convert_to_int(organization_id)
google_civic_election_id = convert_to_int(request.GET.get('google_civic_election_id', 0))
organization_on_stage_found = False
try:
organization_query = Organization.objects.filter(id=organization_id)
if organization_query.count():
organization_on_stage = organization_query[0]
organization_on_stage_found = True
except Exception as e:
handle_record_not_found_exception(e, logger=logger)
organization_on_stage_found = False
if not organization_on_stage_found:
messages.add_message(request, messages.ERROR,
'Could not find organization when trying to retrieve positions.')
return HttpResponseRedirect(reverse('organization:organization_list', args=()))
else:
organization_position_list_found = False
try:
organization_position_list = PositionEntered.objects.order_by('stance')
organization_position_list = organization_position_list.filter(organization_id=organization_id)
if positive_value_exists(google_civic_election_id):
organization_position_list = organization_position_list.filter(
google_civic_election_id=google_civic_election_id)
if len(organization_position_list):
organization_position_list_found = True
except Exception as e:
handle_record_not_found_exception(e, logger=logger)
election_list = Election.objects.order_by('-election_day_text')
if organization_position_list_found:
template_values = {
'messages_on_stage': messages_on_stage,
'organization': organization_on_stage,
'organization_position_list': organization_position_list,
'election_list': election_list,
'google_civic_election_id': google_civic_election_id,
}
else:
template_values = {
'messages_on_stage': messages_on_stage,
'organization': organization_on_stage,
'election_list': election_list,
'google_civic_election_id': google_civic_election_id,
}
return render(request, 'organization/organization_position_list.html', template_values)
示例8: update_organization_twitter_details
def update_organization_twitter_details(self, organization, twitter_json):
"""
Update an organization entry with details retrieved from the Twitter API.
"""
success = False
status = "ENTERING_UPDATE_ORGANIZATION_TWITTER_DETAILS"
values_changed = False
if organization:
if positive_value_exists(twitter_json['id']):
if convert_to_int(twitter_json['id']) != organization.twitter_user_id:
organization.twitter_user_id = convert_to_int(twitter_json['id'])
values_changed = True
if positive_value_exists(twitter_json['screen_name']):
if twitter_json['screen_name'] != organization.organization_twitter_handle:
organization.organization_twitter_handle = twitter_json['screen_name']
values_changed = True
if positive_value_exists(twitter_json['name']):
if twitter_json['name'] != organization.twitter_name:
organization.twitter_name = twitter_json['name']
values_changed = True
if positive_value_exists(twitter_json['followers_count']):
if convert_to_int(twitter_json['followers_count']) != organization.twitter_followers_count:
organization.twitter_followers_count = convert_to_int(twitter_json['followers_count'])
values_changed = True
if positive_value_exists(twitter_json['profile_image_url_https']):
if twitter_json['profile_image_url_https'] != organization.twitter_profile_image_url_https:
organization.twitter_profile_image_url_https = twitter_json['profile_image_url_https']
values_changed = True
if positive_value_exists(twitter_json['description']):
if twitter_json['description'] != organization.twitter_description:
organization.twitter_description = twitter_json['description']
values_changed = True
if positive_value_exists(twitter_json['location']):
if twitter_json['location'] != organization.twitter_location:
organization.twitter_location = twitter_json['location']
values_changed = True
if values_changed:
organization.save()
success = True
status = "SAVED_ORG_TWITTER_DETAILS"
else:
success = True
status = "NO_CHANGES_SAVED_TO_ORG_TWITTER_DETAILS"
results = {
'success': success,
'status': status,
'organization': organization,
}
return results
示例9: positions_public_count_for_contest_measure
def positions_public_count_for_contest_measure(measure_id, measure_we_vote_id, stance_we_are_looking_for):
"""
We want to return a JSON file with the number of orgs and public figures who support
this particular measure
"""
# This implementation is built to make only two database calls. All other calculations are done here in the
# application layer
position_list_manager = PositionListManager()
all_positions_count_for_contest_measure = \
position_list_manager.retrieve_public_positions_count_for_contest_measure(
measure_id, measure_we_vote_id, stance_we_are_looking_for)
if positive_value_exists(measure_id) or positive_value_exists(measure_we_vote_id):
contest_measure_manager = ContestMeasureManager()
# Since we can take in either measure_id or measure_we_vote_id, we need to retrieve the value we don't have
if positive_value_exists(measure_id):
measure_we_vote_id = contest_measure_manager.fetch_contest_measure_we_vote_id_from_id(measure_id)
elif positive_value_exists(measure_we_vote_id):
measure_id = contest_measure_manager.fetch_contest_measure_id_from_we_vote_id(measure_we_vote_id)
json_data = {
'status': 'SUCCESSFUL_RETRIEVE_OF_PUBLIC_POSITION_COUNT_FOR_CONTEST_MEASURE',
'success': True,
'count': all_positions_count_for_contest_measure,
'ballot_item_id': convert_to_int(measure_id),
'ballot_item_we_vote_id': measure_we_vote_id,
'kind_of_ballot_item': MEASURE,
}
results = {
'json_data': json_data,
}
return results
示例10: election_edit_view
def election_edit_view(request, election_local_id):
authority_required = {'admin'} # admin, verified_volunteer
if not voter_has_authority(request, authority_required):
return redirect_to_sign_in_page(request, authority_required)
messages_on_stage = get_messages(request)
election_local_id = convert_to_int(election_local_id)
election_on_stage_found = False
election_on_stage = Election()
try:
election_on_stage = Election.objects.get(id=election_local_id)
election_on_stage_found = True
except Election.MultipleObjectsReturned as e:
handle_record_found_more_than_one_exception(e, logger=logger)
except Election.DoesNotExist:
# This is fine, create new
pass
if election_on_stage_found:
template_values = {
'messages_on_stage': messages_on_stage,
'election': election_on_stage,
}
else:
template_values = {
'messages_on_stage': messages_on_stage,
}
return render(request, "election/election_edit.html", template_values)
示例11: positions_import_from_master_server_view
def positions_import_from_master_server_view(request):
google_civic_election_id = convert_to_int(request.GET.get('google_civic_election_id', 0))
state_code = request.GET.get('state_code', '')
if not positive_value_exists(google_civic_election_id):
messages.add_message(request, messages.INFO, 'Google civic election id is required for Positions import.')
return HttpResponseRedirect(reverse('admin_tools:sync_dashboard', args=()) + "?google_civic_election_id=" +
str(google_civic_election_id) + "&state_code=" + str(state_code))
results = positions_import_from_master_server(request, google_civic_election_id)
if not results['success']:
messages.add_message(request, messages.ERROR, results['status'])
else:
messages.add_message(request, messages.INFO, 'Positions import completed. '
'Saved: {saved}, Updated: {updated}, '
'Master data not imported (local duplicates found): '
'{duplicates_removed}, '
'Not processed: {not_processed}'
''.format(saved=results['saved'],
updated=results['updated'],
duplicates_removed=results['duplicates_removed'],
not_processed=results['not_processed']))
return HttpResponseRedirect(reverse('admin_tools:sync_dashboard', args=()) + "?google_civic_election_id=" +
str(google_civic_election_id) + "&state_code=" + str(state_code))
示例12: quick_info_summary_view
def quick_info_summary_view(request, quick_info_id): # TODO to be updated
authority_required = {'verified_volunteer'} # admin, verified_volunteer
if not voter_has_authority(request, authority_required):
return redirect_to_sign_in_page(request, authority_required)
messages_on_stage = get_messages(request)
quick_info_id = convert_to_int(quick_info_id)
quick_info_on_stage_found = False
quick_info_on_stage = QuickInfo()
try:
quick_info_on_stage = QuickInfo.objects.get(id=quick_info_id)
quick_info_on_stage_found = True
except QuickInfo.MultipleObjectsReturned as e:
handle_record_found_more_than_one_exception(e, logger=logger)
except QuickInfo.DoesNotExist:
# This is fine, create new
pass
if quick_info_on_stage_found:
template_values = {
'messages_on_stage': messages_on_stage,
'quick_info': quick_info_on_stage,
}
else:
template_values = {
'messages_on_stage': messages_on_stage,
}
return render(request, 'quick_info/quick_info_summary.html', template_values)
示例13: voter_summary_view
def voter_summary_view(request, voter_id):
authority_required = {'admin'} # admin, verified_volunteer
if not voter_has_authority(request, authority_required):
return redirect_to_sign_in_page(request, authority_required)
messages_on_stage = get_messages(request)
voter_id = convert_to_int(voter_id)
voter_on_stage_found = False
try:
voter_on_stage = Voter.objects.get(id=voter_id)
voter_on_stage_found = True
except Voter.MultipleObjectsReturned as e:
handle_record_found_more_than_one_exception(e, logger=logger)
except Voter.DoesNotExist:
# This is fine, create new
pass
if voter_on_stage_found:
template_values = {
'messages_on_stage': messages_on_stage,
'voter': voter_on_stage,
}
else:
template_values = {
'messages_on_stage': messages_on_stage,
}
return render(request, 'voter/voter_summary.html', template_values)
示例14: candidate_list_view
def candidate_list_view(request):
authority_required = {'verified_volunteer'} # admin, verified_volunteer
if not voter_has_authority(request, authority_required):
return redirect_to_sign_in_page(request, authority_required)
messages_on_stage = get_messages(request)
google_civic_election_id = convert_to_int(request.GET.get('google_civic_election_id', 0))
candidate_list = []
try:
candidate_list = CandidateCampaign.objects.all()
if positive_value_exists(google_civic_election_id):
candidate_list = candidate_list.filter(google_civic_election_id=google_civic_election_id)
candidate_list = candidate_list.order_by('candidate_name')[:500]
except CandidateCampaign.DoesNotExist:
# This is fine, create new
pass
election_list = Election.objects.order_by('-election_day_text')
template_values = {
'messages_on_stage': messages_on_stage,
'candidate_list': candidate_list,
'election_list': election_list,
'google_civic_election_id': google_civic_election_id,
}
return render(request, 'candidate/candidate_list.html', template_values)
示例15: position_edit_view
def position_edit_view(request, position_id):
authority_required = {'verified_volunteer'} # admin, verified_volunteer
if not voter_has_authority(request, authority_required):
return redirect_to_sign_in_page(request, authority_required)
messages_on_stage = get_messages(request)
position_id = convert_to_int(position_id)
position_on_stage_found = False
try:
position_on_stage = CandidateCampaign.objects.get(id=position_id)
position_on_stage_found = True
except CandidateCampaign.MultipleObjectsReturned as e:
handle_record_found_more_than_one_exception(e, logger=logger)
except CandidateCampaign.DoesNotExist:
# This is fine, create new
pass
if position_on_stage_found:
template_values = {
'messages_on_stage': messages_on_stage,
'position': position_on_stage,
}
else:
template_values = {
'messages_on_stage': messages_on_stage,
}
return render(request, 'position/position_edit.html', template_values)