import logging

from django.contrib.auth import get_user_model
from django.core.exceptions import ObjectDoesNotExist

from users.models import UserInfo

User = get_user_model()

_log = logging.getLogger(__name__)


def create_admin_userinfo(sender, *args, **kwargs):
    try:
        user = User.objects.get(username='admin')
        UserInfo.objects.get_or_create(user=user, comment="admin")
    except ObjectDoesNotExist:
        _log.critical("Admin does not exist")
