# Path: dropbeat/exceptions.py
# class UserException(DropbeatException):
#     pass
# 
# class TrackException(DropbeatException):
#     pass
# 
# class PlaylistException(DropbeatException):
#     pass
# 
# Path: dropbeat/constants.py
# class ErrorCode:
#     """Error codes for HTTP response.
# 
#     """
#     DUPLICATED_EMAIL = '100'
#     INVALID_EMAIL = '101'
#     PASSWORD_TOO_SHORT = '102'
#     EMAIL_NOT_EXIST = '103'
#     PASSWORD_MISMATCH = '104'
#     DUPLICATED_PLAYLIST_NAME = '105'
#     TRACK_ALREADY_EXIST = '106'
#     PLAYLIST_NOT_EXIST = '107'
#     TRACK_NOT_EXIST = '108'
#     RESULT_NOT_READY = '109'
#     INVALID_ACCESS = '110'
# 
# class TrackSource(ChoiceEnum):
#     """Streaming source of track.
# 
#     """
#     youtube = 0
#     soundcloud = 1


import hashlib
import datetime
from dropbeat.exceptions import (
    UserException, TrackException, PlaylistException)
from dropbeat.constants import ErrorCode, TrackSource
from django.db import models, IntegrityError
from django.core.validators import validate_email
from django.core.exceptions import ValidationError, ObjectDoesNotExist
from django.contrib.auth.models import BaseUserManager




class UserManager(BaseUserManager):
    def create_user(self, email, password):
        # 1. Validate email address.
        try:
            validate_email(email)
        except ValidationError:
            raise UserException(ErrorCode.INVALID_EMAIL)

        # 2. Validate password format.
        min_password_len = 8
        if len(password) < min_password_len:

# Path: dropbeat/exceptions.py
# class UserException(DropbeatException):
#     pass
# 
# class TrackException(DropbeatException):
#     pass
# 
# class PlaylistException(DropbeatException):
#     pass
# 
# Path: dropbeat/constants.py
# class ErrorCode:
#     """Error codes for HTTP response.
# 
#     """
#     DUPLICATED_EMAIL = '100'
#     INVALID_EMAIL = '101'
#     PASSWORD_TOO_SHORT = '102'
#     EMAIL_NOT_EXIST = '103'
#     PASSWORD_MISMATCH = '104'
#     DUPLICATED_PLAYLIST_NAME = '105'
#     TRACK_ALREADY_EXIST = '106'
#     PLAYLIST_NOT_EXIST = '107'
#     TRACK_NOT_EXIST = '108'
#     RESULT_NOT_READY = '109'
#     INVALID_ACCESS = '110'
# 
# class TrackSource(ChoiceEnum):
#     """Streaming source of track.
# 
#     """
#     youtube = 0
#     soundcloud = 1


# Path: dropbeat/managers.py
import hashlib
import datetime
from dropbeat.exceptions import (
    UserException, TrackException, PlaylistException)
from dropbeat.constants import ErrorCode, TrackSource
from django.db import models, IntegrityError
from django.core.validators import validate_email
from django.core.exceptions import ValidationError, ObjectDoesNotExist
from django.contrib.auth.models import BaseUserManager





class UserManager(BaseUserManager):
    def create_user(self, email, password):
        # 1. Validate email address.
        try:
            validate_email(email)
        except ValidationError:
            raise UserException(ErrorCode.INVALID_EMAIL)

        # 2. Validate password format.
        min_password_len = 8
        if len(password) < min_password_len:

            raise UserException(ErrorCode.PASSWORD_TOO_SHORT)