Ejemplo n.º 1
0
    def test_functions(self):
        get_switch_list()
        get_hangupcause_name(self.hangupcause.pk)
        get_hangupcause_name(2)

        get_hangupcause_id(self.hangupcause.code)

        # Template tags
        hangupcause_name_with_title(self.hangupcause.pk)
        value = {'_id': {'val': 1}}
        mongo_id(value, 'val')

        get_hc_list()
        get_country_id(['44', '442'])
Ejemplo n.º 2
0
    def test_functions(self):
        get_switch_list()
        get_hangupcause_name(self.hangupcause.pk)
        get_hangupcause_name(2)

        get_hangupcause_id(self.hangupcause.code)

        # Template tags
        hangupcause_name_with_title(self.hangupcause.pk)
        value = {'_id': {'val': 1}}
        mongo_id(value, 'val')

        get_hc_list()
        get_country_id(['44', '442'])
Ejemplo n.º 3
0
def chk_destination(destination_number):
    """
    >>> chk_destination('1234567890')
    {
        'authorized': 0,
        'country_id': 0,
    }
    """
    #remove prefix
    sanitized_destination = remove_prefix(destination_number,
                                          settings.PREFIX_TO_IGNORE)

    prefix_list = prefix_list_string(sanitized_destination)

    authorized = 1  # default
    # check destion against whitelist
    authorized = chk_prefix_in_whitelist(prefix_list)
    if authorized:
        authorized = 1
    else:
        # check against blacklist
        authorized = chk_prefix_in_blacklist(prefix_list)
        if not authorized:
            # not allowed destination
            authorized = 0

    if (len(sanitized_destination) < settings.PN_MIN_DIGITS
            or sanitized_destination[:1].isalpha()):
        # It might be an extension
        country_id = 0
    elif (len(sanitized_destination) >= settings.PN_MIN_DIGITS
          and len(sanitized_destination) <= settings.PN_MAX_DIGITS):
        # It might be an local call
        # Need to add coma for get_country_id to eval correctly
        country_id = get_country_id(str(settings.LOCAL_DIALCODE) + ',')
    else:
        # International call
        country_id = get_country_id(prefix_list)

    destination_data = {
        'authorized': authorized,
        'country_id': country_id,
    }
    return destination_data
Ejemplo n.º 4
0
def chk_destination(destination_number):
    """
    >>> chk_destination('1234567890')
    {
        'authorized': 0,
        'country_id': 0,
    }
    """
    #remove prefix
    sanitized_destination = remove_prefix(destination_number,
        settings.PREFIX_TO_IGNORE)

    prefix_list = prefix_list_string(sanitized_destination)

    authorized = 1  # default
    # check destion against whitelist
    authorized = chk_prefix_in_whitelist(prefix_list)
    if authorized:
        authorized = 1
    else:
        # check against blacklist
        authorized = chk_prefix_in_blacklist(prefix_list)
        if not authorized:
            # not allowed destination
            authorized = 0

    if (len(sanitized_destination) < settings.PN_MIN_DIGITS
       or sanitized_destination[:1].isalpha()):
        # It might be an extension
        country_id = 0
    elif (len(sanitized_destination) >= settings.PN_MIN_DIGITS
         and len(sanitized_destination) <= settings.PN_MAX_DIGITS):
        # It might be an local call
        # Need to add coma for get_country_id to eval correctly
        country_id = get_country_id(str(settings.LOCAL_DIALCODE) + ',')
    else:
        # International call
        country_id = get_country_id(prefix_list)

    destination_data = {
        'authorized': authorized,
        'country_id': country_id,
    }
    return destination_data