Beispiel #1
0
def user_pk_to_url_str(user):
    """
    This should return a string.
    """
    User = get_user_model()
    if issubclass(type(User._meta.pk), models.UUIDField):
        if isinstance(user.pk, six.string_types):
            return user.pk
        return user.pk.hex

    ret = user.pk
    if isinstance(ret, six.integer_types):
        ret = int_to_base36(user.pk)
    return str(ret)
Beispiel #2
0
 def test_int_to_base36(self):
     n = 55798679658823689999
     b36 = 'brxk553wvxbf3'
     assert int_to_base36(n) == b36
     assert base36_to_int(b36) == n
Beispiel #3
0
 def test_int_to_base36(self):
     n = 55798679658823689999
     b36 = 'brxk553wvxbf3'
     assert int_to_base36(n) == b36
     assert base36_to_int(b36) == n