]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Add stripped nick to the player record when adding or changing nicks.
authorAnt Zucaro <azucaro@gmail.com>
Thu, 17 Nov 2011 15:51:59 +0000 (10:51 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Thu, 17 Nov 2011 15:51:59 +0000 (10:51 -0500)
xonstat/views/submission.py

index 031955a8e31a7584200efe3e03e1548930a28a40..fcd291b56a5e3113021f4bbddb9e45425eed24d5 100755 (executable)
@@ -117,14 +117,15 @@ def register_new_nick(session, player, new_nick):
            # player_id/stripped_nick not found, create one\r
         # but we don't store "Anonymous Player #N"\r
         if not re.search('^Anonymous Player #\d+$', player.nick):\r
-           player_nick = PlayerNick()\r
+            player_nick = PlayerNick()\r
             player_nick.player_id = player.player_id\r
-            player_nick.stripped_nick = stripped_nick\r
+            player_nick.stripped_nick = player.stripped_nick\r
             player_nick.nick = player.nick\r
             session.add(player_nick)\r
 \r
     # We change to the new nick regardless\r
     player.nick = new_nick\r
+    player.stripped_nick = strip_colors(new_nick)\r
     session.add(player)\r
 \r
 \r
@@ -249,12 +250,14 @@ def get_or_create_player(session=None, hashkey=None, nick=None):
             session.add(player)\r
             session.flush()\r
 \r
-           # if nick is given to us, use it. If not, use "Anonymous Player"\r
-            # with a suffix added for uniqueness.\r
-            if nick:\r
-                player.nick = nick[:128]\r
-           else:\r
-                player.nick = "Anonymous Player #{0}".format(player.player_id)\r
+        # if nick is given to us, use it. If not, use "Anonymous Player"\r
+        # with a suffix added for uniqueness.\r
+        if nick:\r
+            player.nick = nick[:128]\r
+            player.stripped_nick = strip_colors(nick[:128])\r
+        else:\r
+            player.nick = "Anonymous Player #{0}".format(player.player_id)\r
+            player.stripped_nick = player.nick\r
 \r
             hashkey = Hashkey(player_id=player.player_id, hashkey=hashkey)\r
             session.add(hashkey)\r