# Path: server/apps/authentication/tasks.py
# def send_new_user_notification(id, username, email):
#     '''
#     Information about the ContactMe form is sent via
#     SQS to an EB worker, who will then send notifications
#     to our Staff
# 
#     :param instance: ContactMessage object to email
#     :return: Nothing
#     '''
# 
#     subject = 'User @{0} (ID={1}) has registered with email {2}'.format(username, id, email)
# 
#     logger.debug(subject)


import hashlib
import logging
import os
import urllib.parse
import uuid
import pytz
from django.conf import settings
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager
from django.db import models
from django.db.models import Q
from django.template.defaultfilters import slugify
from allauth.account.signals import user_signed_up
from rest_framework.authtoken.models import Token
from .tasks import send_new_user_notification
"""
Custom User Model
"""

# import code for encoding urls and generating md5 hashes





# Get an instance of a logger
logger = logging.getLogger(__name__)


def new_sign_up(sender, **kwargs):
    account = kwargs['user']
    logger.info('A new user has signed up! - {username}'.format(username=account.username))
    logger.debug('--> New User: ' + str(account))

# Path: server/apps/authentication/tasks.py
# def send_new_user_notification(id, username, email):
#     '''
#     Information about the ContactMe form is sent via
#     SQS to an EB worker, who will then send notifications
#     to our Staff
# 
#     :param instance: ContactMessage object to email
#     :return: Nothing
#     '''
# 
#     subject = 'User @{0} (ID={1}) has registered with email {2}'.format(username, id, email)
# 
#     logger.debug(subject)


# Path: server/apps/authentication/models.py
import hashlib
import logging
import os
import urllib.parse
import uuid
import pytz
from django.conf import settings
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager
from django.db import models
from django.db.models import Q
from django.template.defaultfilters import slugify
from allauth.account.signals import user_signed_up
from rest_framework.authtoken.models import Token
from .tasks import send_new_user_notification

"""
Custom User Model
"""

# import code for encoding urls and generating md5 hashes





# Get an instance of a logger
logger = logging.getLogger(__name__)


def new_sign_up(sender, **kwargs):
    account = kwargs['user']
    logger.info('A new user has signed up! - {username}'.format(username=account.username))
    logger.debug('--> New User: ' + str(account))

    send_new_user_notification(id=account.id, username=account.username, email=account.email)