# Path: custom_user_tests/models.py
# class CustomUser(AbstractBaseUser, PermissionsMixin):
#     objects = UserManager()
#     my_custom_field = models.CharField(max_length=50, blank=True, null=True)
# 
#     class Meta:
#         app_label = 'custom_user_tests'
#         verbose_name = _('user')
#         verbose_name_plural = _('users')
# 
#     username = models.CharField(
#         _('username'), max_length=30, unique=True,
#         help_text=_('Required. 30 characters or fewer. Letters, digits and '
#                     '@/./+/-/_ only.'),
#         validators=[
#             validators.RegexValidator(r'^[\w.@+-]+$', _('Enter a valid username.'), 'invalid')
#         ])
#     first_name = models.CharField(_('first name'), max_length=30, blank=True)
#     last_name = models.CharField(_('last name'), max_length=30, blank=True)
#     email = models.EmailField(_('email address'), blank=True)
#     is_staff = models.BooleanField(
#         _('staff status'), default=False,
#         help_text=_('Designates whether the user can log into this admin '
#                     'site.'))
#     is_active = models.BooleanField(
#         _('active'), default=True,
#         help_text=_('Designates whether this user should be treated as '
#                     'active. Unselect this instead of deleting accounts.'))
#     date_joined = models.DateTimeField(_('date joined'), default=timezone.now)
# 
#     USERNAME_FIELD = 'username'
#     REQUIRED_FIELDS = ['email']
# 
#     def get_full_name(self):
#         """
#         Returns the first_name plus the last_name, with a space in between.
#         """
#         full_name = '%s %s' % (self.first_name, self.last_name)
#         return full_name.strip()
# 
#     def get_short_name(self):
#         "Returns the short name for the user."
#         return self.first_name


from custom_user_tests.models import CustomUser
from django import forms
from django.contrib.auth import get_user_model
from django.utils.translation import ugettext_lazy as _
    """ Hardcoded credentials to demonstrate that the get_credentials method
    is being used
    """
    error_messages = {
        'duplicate_username': _("A user with that username already exists."),
        'password_mismatch': _("The two password fields didn't match."),
    }
    username = forms.RegexField(
        label=_("Username"), max_length=30,
        regex=r'^[\w.@+-]+$',
        help_text=_("Required. 30 characters or fewer. Letters, digits and "
                    "@/./+/-/_ only."),
        error_messages={
            'invalid': _("This value may contain only letters, numbers and "
                         "@/./+/-/_ characters.")})
    password1 = forms.CharField(
        label=_("Password"),
        widget=forms.PasswordInput)
    password2 = forms.CharField(
        label=_("Password confirmation"),
        widget=forms.PasswordInput,
        help_text=_("Enter the same password as above, for verification."))

    def get_credentials(self):
        return {
            'username': 'demo',
            'password': 'demo',
        }

    class Meta:

# Path: custom_user_tests/models.py
# class CustomUser(AbstractBaseUser, PermissionsMixin):
#     objects = UserManager()
#     my_custom_field = models.CharField(max_length=50, blank=True, null=True)
# 
#     class Meta:
#         app_label = 'custom_user_tests'
#         verbose_name = _('user')
#         verbose_name_plural = _('users')
# 
#     username = models.CharField(
#         _('username'), max_length=30, unique=True,
#         help_text=_('Required. 30 characters or fewer. Letters, digits and '
#                     '@/./+/-/_ only.'),
#         validators=[
#             validators.RegexValidator(r'^[\w.@+-]+$', _('Enter a valid username.'), 'invalid')
#         ])
#     first_name = models.CharField(_('first name'), max_length=30, blank=True)
#     last_name = models.CharField(_('last name'), max_length=30, blank=True)
#     email = models.EmailField(_('email address'), blank=True)
#     is_staff = models.BooleanField(
#         _('staff status'), default=False,
#         help_text=_('Designates whether the user can log into this admin '
#                     'site.'))
#     is_active = models.BooleanField(
#         _('active'), default=True,
#         help_text=_('Designates whether this user should be treated as '
#                     'active. Unselect this instead of deleting accounts.'))
#     date_joined = models.DateTimeField(_('date joined'), default=timezone.now)
# 
#     USERNAME_FIELD = 'username'
#     REQUIRED_FIELDS = ['email']
# 
#     def get_full_name(self):
#         """
#         Returns the first_name plus the last_name, with a space in between.
#         """
#         full_name = '%s %s' % (self.first_name, self.last_name)
#         return full_name.strip()
# 
#     def get_short_name(self):
#         "Returns the short name for the user."
#         return self.first_name


# Path: custom_user_tests/forms.py
from custom_user_tests.models import CustomUser
from django import forms
from django.contrib.auth import get_user_model
from django.utils.translation import ugettext_lazy as _

    """ Hardcoded credentials to demonstrate that the get_credentials method
    is being used
    """
    error_messages = {
        'duplicate_username': _("A user with that username already exists."),
        'password_mismatch': _("The two password fields didn't match."),
    }
    username = forms.RegexField(
        label=_("Username"), max_length=30,
        regex=r'^[\w.@+-]+$',
        help_text=_("Required. 30 characters or fewer. Letters, digits and "
                    "@/./+/-/_ only."),
        error_messages={
            'invalid': _("This value may contain only letters, numbers and "
                         "@/./+/-/_ characters.")})
    password1 = forms.CharField(
        label=_("Password"),
        widget=forms.PasswordInput)
    password2 = forms.CharField(
        label=_("Password confirmation"),
        widget=forms.PasswordInput,
        help_text=_("Enter the same password as above, for verification."))

    def get_credentials(self):
        return {
            'username': 'demo',
            'password': 'demo',
        }

    class Meta:

        model = CustomUser