• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.convert_to_int函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中wevote_functions.models.convert_to_int函数的典型用法代码示例。如果您正苦于以下问题:Python convert_to_int函数的具体用法?Python convert_to_int怎么用?Python convert_to_int使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了convert_to_int函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: 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
开发者ID:JesseAldridge,项目名称:WeVoteServer,代码行数:60,代码来源:models.py


示例2: 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:
    """
    # If person isn't signed in, we don't want to let them visit this page yet
    if not request.user.is_authenticated():
        return redirect('/admin')

    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)
    except Organization.DoesNotExist as e:
        # This is fine, create new
        handle_exception_silently(e)

    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

    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,
        }

    return render(request, 'organization/organization_position_edit.html', template_values)
开发者ID:zvxr,项目名称:WeVoteBase,代码行数:57,代码来源:views.py


示例3: 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
开发者ID:JesseAldridge,项目名称:WeVoteServer,代码行数:55,代码来源:models.py


示例4: election_summary_view

def election_summary_view(request, election_local_id):
    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_summary.html', template_values)
开发者ID:JesseAldridge,项目名称:WeVoteServer,代码行数:25,代码来源:views_admin.py


示例5: organization_add_new_position_form_view

def organization_add_new_position_form_view(request, organization_id):
    messages_on_stage = get_messages(request)
    organization_id = convert_to_int(organization_id)
    all_is_well = True
    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 create a new position.')
        return HttpResponseRedirect(reverse('organization:organization_position_list', args=([organization_id])))

    # Prepare a drop down of candidates competing in this election
    candidate_campaign_list = CandidateCampaignList()
    candidate_campaigns_for_this_election_list \
        = candidate_campaign_list.retrieve_candidate_campaigns_for_this_election_list()

    if all_is_well:
        template_values = {
            'candidate_campaigns_for_this_election_list':   candidate_campaigns_for_this_election_list,
            'messages_on_stage':                            messages_on_stage,
            'organization':                                 organization_on_stage,
            'organization_position_candidate_campaign_id':  0,
            'possible_stances_list':                        ORGANIZATION_STANCE_CHOICES,
            'stance_selected':                              SUPPORT,  # Default stance
        }
    return render(request, 'organization/organization_position_edit.html', template_values)
开发者ID:marcusbusby,项目名称:WeVoteServer,代码行数:34,代码来源:views_admin.py


示例6: retrieve_candidate_photos_for_election_view

def retrieve_candidate_photos_for_election_view(request, election_id):
    google_civic_election_id = convert_to_int(election_id)

    # We only want to process if a google_civic_election_id comes in
    if not positive_value_exists(google_civic_election_id):
        messages.add_message(request, messages.ERROR, "Google Civic Election ID required.")
        return HttpResponseRedirect(reverse("candidate:candidate_list", args=()))

    try:
        candidate_list = CandidateCampaign.objects.order_by("candidate_name")
        if positive_value_exists(google_civic_election_id):
            candidate_list = candidate_list.filter(google_civic_election_id=google_civic_election_id)
    except CandidateCampaign.DoesNotExist:
        pass

    display_messages = False
    force_retrieve = False
    # Loop through all of the candidates in this election
    for we_vote_candidate in candidate_list:
        retrieve_candidate_results = retrieve_candidate_photos(we_vote_candidate, force_retrieve)

        if retrieve_candidate_results["status"] and display_messages:
            messages.add_message(request, messages.INFO, retrieve_candidate_results["status"])

    return HttpResponseRedirect(
        reverse("candidate:candidate_list", args=())
        + "?google_civic_election_id={var}".format(var=google_civic_election_id)
    )
开发者ID:JesseAldridge,项目名称:WeVoteServer,代码行数:28,代码来源:views_admin.py


示例7: polling_location_edit_process_view

def polling_location_edit_process_view(request):
    """
    Process the new or edit polling_location forms
    :param request:
    :return:
    """
    polling_location_id = convert_to_int(request.POST['polling_location_id'])
    polling_location_name = request.POST['polling_location_name']

    # Check to see if this polling_location is already being used anywhere
    polling_location_on_stage_found = False
    try:
        polling_location_query = PollingLocation.objects.filter(id=polling_location_id)
        if len(polling_location_query):
            polling_location_on_stage = polling_location_query[0]
            polling_location_on_stage_found = True
    except Exception as e:
        handle_record_not_found_exception(e, logger=logger)

    try:
        if polling_location_on_stage_found:
            # Update
            polling_location_on_stage.polling_location_name = polling_location_name
            polling_location_on_stage.save()
            messages.add_message(request, messages.INFO, 'PollingLocation updated.')
        else:
            # Create new
            messages.add_message(request, messages.INFO, 'We do not support adding new polling locations.')
    except Exception as e:
        handle_record_not_saved_exception(e, logger=logger)
        messages.add_message(request, messages.ERROR, 'Could not save polling_location.')

    return HttpResponseRedirect(reverse('polling_location:polling_location_list', args=()))
开发者ID:JesseAldridge,项目名称:WeVoteServer,代码行数:33,代码来源:views_admin.py


示例8: measure_edit_view

def measure_edit_view(request, measure_id):
    messages_on_stage = get_messages(request)
    measure_id = convert_to_int(measure_id)
    measure_on_stage_found = False
    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)
        measure_on_stage = ContestMeasure()
    except ContestMeasure.DoesNotExist:
        # This is fine, create new
        measure_on_stage = ContestMeasure()
        pass

    if measure_on_stage_found:
        template_values = {
            'messages_on_stage': messages_on_stage,
            'measure': measure_on_stage,
        }
    else:
        template_values = {
            'messages_on_stage': messages_on_stage,
        }
    return render(request, 'measure/measure_edit.html', template_values)
开发者ID:thaddeusphoenix,项目名称:WeVoteServer,代码行数:25,代码来源:views_admin.py


示例9: measure_summary_view

def measure_summary_view(request, measure_id):
    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 = 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)
开发者ID:thaddeusphoenix,项目名称:WeVoteServer,代码行数:29,代码来源:views_admin.py


示例10: fetch_next_id_we_vote_last_org_integer

def fetch_next_id_we_vote_last_org_integer():
    we_vote_settings_manager = WeVoteSettingsManager()
    id_we_vote_last_org_integer = we_vote_settings_manager.fetch_setting('id_we_vote_last_org_integer')
    id_we_vote_last_org_integer = convert_to_int(id_we_vote_last_org_integer)
    id_we_vote_last_org_integer += 1
    we_vote_settings_manager.save_setting('id_we_vote_last_org_integer', id_we_vote_last_org_integer)
    return id_we_vote_last_org_integer
开发者ID:ondrae,项目名称:WeVoteBase,代码行数:7,代码来源:models.py


示例11: fetch_next_we_vote_id_last_voter_integer

def fetch_next_we_vote_id_last_voter_integer():
    we_vote_settings_manager = WeVoteSettingsManager()
    we_vote_id_last_voter_integer = we_vote_settings_manager.fetch_setting('we_vote_id_last_voter_integer')
    we_vote_id_last_voter_integer = convert_to_int(we_vote_id_last_voter_integer)
    we_vote_id_last_voter_integer += 1
    we_vote_settings_manager.save_setting('we_vote_id_last_voter_integer', we_vote_id_last_voter_integer)
    return we_vote_id_last_voter_integer
开发者ID:thaddeusphoenix,项目名称:WeVoteServer,代码行数:7,代码来源:models.py


示例12: fetch_next_id_we_vote_last_position_integer

def fetch_next_id_we_vote_last_position_integer():
    we_vote_settings_manager = WeVoteSettingsManager()
    id_we_vote_last_position_integer = we_vote_settings_manager.fetch_setting("id_we_vote_last_position_integer")
    id_we_vote_last_position_integer = convert_to_int(id_we_vote_last_position_integer)
    id_we_vote_last_position_integer += 1
    we_vote_settings_manager.save_setting("id_we_vote_last_position_integer", id_we_vote_last_position_integer)
    return id_we_vote_last_position_integer
开发者ID:zvxr,项目名称:WeVoteBase,代码行数:7,代码来源:models.py


示例13: organization_edit_view

def organization_edit_view(request, organization_id):
    # If person isn't signed in, we don't want to let them visit this page yet
    if not request.user.is_authenticated():
        return redirect('/admin')

    messages_on_stage = get_messages(request)
    organization_id = convert_to_int(organization_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)
    except Organization.DoesNotExist as e:
        # This is fine, create new
        handle_exception_silently(e)

    if organization_on_stage_found:
        template_values = {
            'messages_on_stage': messages_on_stage,
            'organization': organization_on_stage,
        }
    else:
        template_values = {
            'messages_on_stage': messages_on_stage,
        }
    return render(request, 'organization/organization_edit.html', template_values)
开发者ID:zvxr,项目名称:WeVoteBase,代码行数:27,代码来源:views.py


示例14: election_edit_process_view

def election_edit_process_view(request):
    """
    Process the new or edit election forms
    :param request:
    :return:
    """
    election_id = convert_to_int(request.POST["election_id"])
    election_name = request.POST["election_name"]

    # Check to see if this election is already being used anywhere
    election_on_stage_found = False
    try:
        election_query = Election.objects.filter(id=election_id)
        if len(election_query):
            election_on_stage = election_query[0]
            election_on_stage_found = True
    except Exception as e:
        handle_record_not_found_exception(e, logger=logger)

    try:
        if election_on_stage_found:
            # Update
            election_on_stage.election_name = election_name
            election_on_stage.save()
            messages.add_message(request, messages.INFO, "Election updated.")
        else:
            # Create new
            election_on_stage = Election(election_name=election_name)
            election_on_stage.save()
            messages.add_message(request, messages.INFO, "New election saved.")
    except Exception as e:
        handle_record_not_saved_exception(e, logger=logger)
        messages.add_message(request, messages.ERROR, "Could not save election.")

    return HttpResponseRedirect(reverse("election:election_list", args=()))
开发者ID:marcusbusby,项目名称:WeVoteServer,代码行数:35,代码来源:views_admin.py


示例15: voter_edit_process_view

def voter_edit_process_view(request):
    """
    Process the new or edit voter forms
    :param request:
    :return:
    """
    voter_id = convert_to_int(request.POST['voter_id'])
    voter_name = request.POST['voter_name']

    # Check to see if this voter is already being used anywhere
    voter_on_stage_found = False
    try:
        voter_query = Voter.objects.filter(id=voter_id)
        if len(voter_query):
            voter_on_stage = voter_query[0]
            voter_on_stage_found = True
    except Exception as e:
        handle_record_not_found_exception(e, logger=logger)

    try:
        if voter_on_stage_found:
            # Update
            voter_on_stage.voter_name = voter_name
            voter_on_stage.save()
            messages.add_message(request, messages.INFO, 'Voter updated.')
        else:
            # Create new
            messages.add_message(request, messages.INFO, 'We do not support adding new Voters.')
    except Exception as e:
        handle_record_not_saved_exception(e, logger=logger)
        messages.add_message(request, messages.ERROR, 'Could not save voter.')

    return HttpResponseRedirect(reverse('voter:voter_list', args=()))
开发者ID:JesseAldridge,项目名称:WeVoteServer,代码行数:33,代码来源:views_admin.py


示例16: organization_retrieve_for_api

def organization_retrieve_for_api(organization_id, organization_we_vote_id):
    organization_id = convert_to_int(organization_id)

    we_vote_id = organization_we_vote_id.strip()
    if not positive_value_exists(organization_id) and not positive_value_exists(organization_we_vote_id):
        json_data = {
            'status': "ORGANIZATION_RETRIEVE_BOTH_IDS_MISSING",
            'success': False,
            'organization_id': organization_id,
            'organization_we_vote_id': organization_we_vote_id,
            'organization_name': '',
            'organization_email': '',
            'organization_website': '',
            'organization_twitter_handle': '',
            'organization_facebook': '',
            'organization_photo_url': '',
        }
        return HttpResponse(json.dumps(json_data), content_type='application/json')

    organization_manager = OrganizationManager()
    results = organization_manager.retrieve_organization(organization_id, organization_we_vote_id)

    if results['organization_found']:
        organization = results['organization']
        json_data = {
            'success': True,
            'status': results['status'],
            'organization_id': organization.id,
            'organization_we_vote_id': organization.we_vote_id,
            'organization_name':
                organization.organization_name if positive_value_exists(organization.organization_name) else '',
            'organization_website': organization.organization_website if positive_value_exists(
                organization.organization_website) else '',
            'organization_twitter_handle':
                organization.organization_twitter_handle if positive_value_exists(
                    organization.organization_twitter_handle) else '',
            'organization_email':
                organization.organization_email if positive_value_exists(organization.organization_email) else '',
            'organization_facebook':
                organization.organization_facebook if positive_value_exists(organization.organization_facebook) else '',
            'organization_photo_url': organization.organization_photo_url()
                if positive_value_exists(organization.organization_photo_url()) else '',
        }
        return HttpResponse(json.dumps(json_data), content_type='application/json')
    else:
        json_data = {
            'status': results['status'],
            'success': False,
            'organization_id': organization_id,
            'organization_we_vote_id': we_vote_id,
            'organization_name': '',
            'organization_email': '',
            'organization_website': '',
            'organization_twitter_handle': '',
            'organization_facebook': '',
            'organization_photo_url': '',
        }
        return HttpResponse(json.dumps(json_data), content_type='application/json')
开发者ID:JesseAldridge,项目名称:WeVoteServer,代码行数:58,代码来源:controllers.py


示例17: quick_info_master_edit_view

def quick_info_master_edit_view(request, quick_info_master_id):
    form_submitted = request.POST.get('form_submitted', False)
    quick_info_master_id = convert_to_int(quick_info_master_id)

    try:
        quick_info_master = QuickInfoMaster.objects.get(id=quick_info_master_id)
    except QuickInfoMaster.MultipleObjectsReturned as e:
        # Pretty unlikely that multiple objects have the same id
        messages.add_message(request, messages.ERROR, "This quick_info_master_id has multiple records.")
        return HttpResponseRedirect(reverse('quick_info:quick_info_master_list', args=()))
    except QuickInfoMaster.DoesNotExist:
        # This is fine, create new entry
        return quick_info_master_new_view(request)

    if positive_value_exists(form_submitted):
        # If the voter tried to submit an entry, and it didn't save, capture the changed values for display
        kind_of_ballot_item = request.POST.get('kind_of_ballot_item', False)
        language = request.POST.get('language', False)
        info_text = request.POST.get('info_text', False)
        info_html = request.POST.get('info_html', False)
        master_entry_name = request.POST.get('master_entry_name', False)
        more_info_credit = request.POST.get('more_info_credit', False)
        more_info_url = request.POST.get('more_info_url', False)

        # Write over the fields where a change has been made on the form
        if kind_of_ballot_item is not False:
            quick_info_master.kind_of_ballot_item = kind_of_ballot_item
        if language is not False:
            quick_info_master.language = language
        if master_entry_name is not False:
            quick_info_master.master_entry_name = master_entry_name
        if more_info_credit is not False:
            quick_info_master.more_info_credit = more_info_credit
        if more_info_url is not False:
            quick_info_master.more_info_url = more_info_url
        if info_text is not False:
            quick_info_master.info_text = info_text
        if info_html is not False:
            quick_info_master.info_html = info_html

    # ##################################
    # Above we have dealt with data provided by prior submit
    quick_info_list = QuickInfo.objects.order_by('id')  # This order_by is temp
    quick_info_list = QuickInfo.objects.filter(quick_info_master_we_vote_id=quick_info_master.we_vote_id)

    messages_on_stage = get_messages(request)

    template_values = {
        'messages_on_stage':            messages_on_stage,
        'ballot_item_choices':          KIND_OF_BALLOT_ITEM_CHOICES,
        'language_choices':             LANGUAGE_CHOICES,
        'quick_info_master':            quick_info_master,
        'quick_info_list':              quick_info_list,
    }
    return render(request, 'quick_info/quick_info_master_edit.html', template_values)
开发者ID:JesseAldridge,项目名称:WeVoteServer,代码行数:55,代码来源:views_admin.py


示例18: organization_delete_existing_position_process_form_view

def organization_delete_existing_position_process_form_view(request, organization_id, position_id):
    """

    :param request:
    :param organization_id:
    :param position_id:
    :return:
    """
    # If person isn't signed in, we don't want to let them visit this page yet
    if not request.user.is_authenticated():
        return redirect('/admin')

    organization_id = convert_to_int(organization_id)
    position_id = convert_to_int(position_id)

    # Get the existing position
    organization_position_on_stage_found = False
    if position_id > 0:
        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 this organization's position when trying to delete.")
        return HttpResponseRedirect(reverse('organization:organization_position_list', args=([organization_id])))

    try:
        organization_position_on_stage.delete()
    except Exception as e:
        handle_record_not_deleted_exception(e)
        messages.add_message(request, messages.ERROR,
                             'Could not delete position.')
        return HttpResponseRedirect(reverse('organization:organization_position_list', args=([organization_id])))

    messages.add_message(request, messages.INFO,
                         'Position deleted.')
    return HttpResponseRedirect(reverse('organization:organization_position_list', args=([organization_id])))
开发者ID:zvxr,项目名称:WeVoteBase,代码行数:42,代码来源:views.py


示例19: get_maximum_number_to_retrieve_from_request

def get_maximum_number_to_retrieve_from_request(request):
    if 'maximum_number_to_retrieve' in request.GET:
        maximum_number_to_retrieve = request.GET['maximum_number_to_retrieve']
    else:
        maximum_number_to_retrieve = 20
    if maximum_number_to_retrieve is "":
        maximum_number_to_retrieve = 20
    else:
        maximum_number_to_retrieve = convert_to_int(maximum_number_to_retrieve)

    return maximum_number_to_retrieve
开发者ID:JesseAldridge,项目名称:WeVoteServer,代码行数:11,代码来源:views.py


示例20: special_interest_group_rating_list_view

def special_interest_group_rating_list_view(request, special_interest_group_id):
    messages_on_stage = get_messages(request)
    special_interest_group_id = convert_to_int(special_interest_group_id)
    # google_civic_election_id = request.GET.get('google_civic_election_id', 0)
    special_interest_group_found = False
    try:
        special_interest_group_query = VoteSmartSpecialInterestGroup.objects.filter(sigId=special_interest_group_id)
        if special_interest_group_query.count():
            special_interest_group = special_interest_group_query[0]
            special_interest_group_found = True
    except VotesmartApiError as error_instance:
        # Catch the error message coming back from Vote Smart and pass it in the status
        error_message = error_instance.args
        status = "EXCEPTION_RAISED: {error_message}".format(error_message=error_message)
        print_to_log(logger=logger, exception_message_optional=status)
        special_interest_group_found = False

    if not special_interest_group_found:
        messages.add_message(request, messages.ERROR,
                             'Could not find special_interest_group when trying to retrieve ratings.')
        return HttpResponseRedirect(reverse('import_export_vote_smart:vote_smart_special_interest_group_list', args=()))
    else:
        rating_list_found = False
        try:
            rating_list = VoteSmartRatingOneCandidate.objects.order_by('-timeSpan')
            rating_list = rating_list.filter(sigId=special_interest_group_id)
            if len(rating_list):
                rating_list_found = True
        except VotesmartApiError as error_instance:
            # Catch the error message coming back from Vote Smart and pass it in the status
            error_message = error_instance.args
            status = "EXCEPTION_RAISED: {error_message}".format(error_message=error_message)
            print_to_log(logger=logger, exception_message_optional=status)

        # election_list = Election.objects.order_by('-election_day_text')

        if rating_list_found:
            template_values = {
                'messages_on_stage': messages_on_stage,
                'special_interest_group': special_interest_group,
                'rating_list': rating_list,
                # 'election_list': election_list,
                # 'google_civic_election_id': google_civic_election_id,
            }
        else:
            template_values = {
                'messages_on_stage': messages_on_stage,
                'special_interest_group': special_interest_group,
                # 'election_list': election_list,
                # 'google_civic_election_id': google_civic_election_id,
            }
    return render(request, 'import_export_vote_smart/group_rating_list.html', template_values)
开发者ID:JesseAldridge,项目名称:WeVoteServer,代码行数:52,代码来源:views_admin.py



注:本文中的wevote_functions.models.convert_to_int函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.get_voter_device_id函数代码示例发布时间:2022-05-26
下一篇:
Python functions.positive_value_exists函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap