diff options
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 66de551da..64c8a14f2 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1039,6 +1039,7 @@ class HierarchicalType(GeneralType): class TinyUrl(models.Model): CHAR_MAP = string.ascii_letters + string.digits + CHAR_MAP_LEN = len(CHAR_MAP) link = models.URLField() @classmethod @@ -1049,8 +1050,8 @@ class TinyUrl(models.Model): c_id = self.id digits = [] while c_id > 0: - digits.append(c_id % 62) - c_id //= 62 + digits.append(c_id % self.CHAR_MAP_LEN) + c_id //= self.CHAR_MAP_LEN digits.reverse() return self.index_to_char(digits) @@ -1058,7 +1059,7 @@ class TinyUrl(models.Model): def decode_id(cls, value): i = 0 for c in value: - i = i * 64 + cls.CHAR_MAP.index(c) + i = i * self.CHAR_MAP_LEN + cls.CHAR_MAP.index(c) return i |