def convert_to_private_name(ssplayername): username = player_username.get(ssplayername) if username != None: lastname, firstname = username.split('_') else: tokens = ssplayername.split(',') lastname = tokens[0] firstname = tokens[1].split()[0] firstname = firstname.capitalize() lastname = lastname.capitalize() return ' '.join([firstname, lastname])
def convert_to_public_name(ssplayername): username = player_username.get(ssplayername) if username != None: lastname, firstname = username.split('_') else: tokens = ssplayername.split(',') lastname = tokens[0] firstname = tokens[1].split()[0] firstname = firstname.capitalize() lastname = lastname.capitalize() public_name = firstname existing_players = Player.objects.filter(public_name=public_name) while len(existing_players) > 0: letter = lastname[0] lastname = lastname[1:] public_name += letter existing_players = Player.objects.filter(public_name=public_name) return public_name