diff --git a/la_chariotte/order/models.py b/la_chariotte/order/models.py index b5fc867..0b72c1c 100644 --- a/la_chariotte/order/models.py +++ b/la_chariotte/order/models.py @@ -34,11 +34,16 @@ class GroupedOrder(models.Model): 2. A random int written in base36 (5 digits long) 3. Only the 6 first digits of this string The use of pk in the beginning of the string guarantees the uniqueness, and the random part makes that we cannot guess the url path. + + We use this kind of code, that is small and can contain a large number of values, in order to keep it simple enough to be + manually written, so that people can share information about grouped orders more easily """ base_36_pk = base36.dumps(self.pk) + # generate a 5 digits long string : the random int is between 11111[in base 36] and zzzzz[in base 36], + # which are the smallest and the biggest values with 5 digits random_string = base36.dumps( random.randint(pow(36, CODE_LENGTH - 2), pow(36, CODE_LENGTH - 1) - 1) - ) # generates a 5 digits long string + ) self.code = f"{base_36_pk}{random_string}"[:CODE_LENGTH] def compute_total_price(self):