def generate_token(self): max_tries, tries = 5, 0 while tries <= max_tries: human_hasher = HumanHasher() human_token, token = human_hasher.uuid() try: Voucher.objects.get(human_token=human_token) tries += 1 except Voucher.DoesNotExist: break return token, human_token
def is_valid_token(self, token): human_hasher = HumanHasher() return human_hasher.humanize(token) == self.human_token
def generate_token(self): human_hasher = HumanHasher() return human_hasher.uuid()