# Path: lobbyauth/models.py
# class UserProfile(models.Model):
#     user = models.OneToOneField(User, on_delete=CASCADE)
#     accountid = models.IntegerField(unique=True)
#     timerank = models.IntegerField()
#     aliases = models.CharField(max_length=2048)
#     country = models.CharField(max_length=2)
#     game_pref = models.SmallIntegerField(default=0)  # id of srs.models.Game
#     game_pref_fixed = models.BooleanField(default=False)
#     is_developer = models.BooleanField(default=False)
# 
#     def __unicode__(self):
#         return "profile for %s (accID: %s | %d)" % (
#             self.user.username,
#             self.user.last_name,
#             self.accountid,
#         )
# 
#     class Meta:
#         ordering = ("user__username",)


import logging
import socket
from xmlrpc.client import ProtocolError, ServerProxy
from django.contrib.auth import get_user_model
from django.contrib.auth.backends import ModelBackend
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist
from .models import UserProfile
                    )
                    # search for unused username
                    counter = 0
                    while User.objects.filter(username="{}_{}".format(username, counter)).exists():
                        counter += 1
                    username = "{}_{}".format(username, counter)
                except ObjectDoesNotExist:
                    # no user already exists that has the same username
                    pass
                user = User.objects.create_user(
                    username=username,
                    email="django@needs.this",
                    password="NoNeedToStoreEvenHashedPasswords",
                )
                # email, so comments form doesn't ask for it
                user.is_staff = False
                user.is_superuser = False
                user.last_name = str(accountid)
                logger.info(
                    "created User(%d) %s (accountID: %s)",
                    user.id,
                    user.username,
                    user.last_name,
                )
                user.save()

            timerank = self._ingame_time_2_rank(accountinfo["ingame_time"])
            aliases = ",".join(accountinfo["aliases"])
            country = accountinfo["country"]


# Path: lobbyauth/models.py
# class UserProfile(models.Model):
#     user = models.OneToOneField(User, on_delete=CASCADE)
#     accountid = models.IntegerField(unique=True)
#     timerank = models.IntegerField()
#     aliases = models.CharField(max_length=2048)
#     country = models.CharField(max_length=2)
#     game_pref = models.SmallIntegerField(default=0)  # id of srs.models.Game
#     game_pref_fixed = models.BooleanField(default=False)
#     is_developer = models.BooleanField(default=False)
# 
#     def __unicode__(self):
#         return "profile for %s (accID: %s | %d)" % (
#             self.user.username,
#             self.user.last_name,
#             self.accountid,
#         )
# 
#     class Meta:
#         ordering = ("user__username",)


# Path: lobbyauth/lobbybackend.py
import logging
import socket
from xmlrpc.client import ProtocolError, ServerProxy
from django.contrib.auth import get_user_model
from django.contrib.auth.backends import ModelBackend
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist
from .models import UserProfile

                    )
                    # search for unused username
                    counter = 0
                    while User.objects.filter(username="{}_{}".format(username, counter)).exists():
                        counter += 1
                    username = "{}_{}".format(username, counter)
                except ObjectDoesNotExist:
                    # no user already exists that has the same username
                    pass
                user = User.objects.create_user(
                    username=username,
                    email="django@needs.this",
                    password="NoNeedToStoreEvenHashedPasswords",
                )
                # email, so comments form doesn't ask for it
                user.is_staff = False
                user.is_superuser = False
                user.last_name = str(accountid)
                logger.info(
                    "created User(%d) %s (accountID: %s)",
                    user.id,
                    user.username,
                    user.last_name,
                )
                user.save()

            timerank = self._ingame_time_2_rank(accountinfo["ingame_time"])
            aliases = ",".join(accountinfo["aliases"])
            country = accountinfo["country"]


            userprofile, up_created = UserProfile.objects.get_or_create(