1 from random import Random
4 from models import ServiceTicket, LoginTicket
6 def _generate_string(length=8, chars=string.letters + string.digits):
7 return ''.join(Random().sample(string.letters+string.digits, length))
9 def create_service_ticket(user, service):
10 ticket_string = 'ST-' + _generate_string(29) # Total ticket length = 29 + 3 = 32
11 ticket = ServiceTicket(service=service, user=user, ticket=ticket_string)
15 def create_login_ticket():
16 ticket_string = 'LT-' + _generate_string(29)
17 ticket = LoginTicket(ticket=ticket_string)