# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import

from django.contrib.auth.forms import UserCreationForm, UserChangeForm

from custom_email_user.models import EmailUser


class EmailUserCreationForm(UserCreationForm):
    """
    A form that creates a user, with no privileges, from the given email and
    password.
    """

    def __init__(self, *args, **kargs):
        super(EmailUserCreationForm, self).__init__(*args, **kargs)
        if 'username' in self.fields.keys():
            del self.fields['username']

    class Meta:
        model = EmailUser
        fields = ("email",)


class EmailUserChangeForm(UserChangeForm):
    """A form for updating users. Includes all the fields on
    the user, but replaces the password field with admin's
    password hash display field.
    """

    def __init__(self, *args, **kargs):
        super(EmailUserChangeForm, self).__init__(*args, **kargs)
        if 'username' in self.fields.keys():
            del self.fields['username']

    class Meta:
        model = EmailUser
        fields = '__all__'

@@ -75,16 +75,47 @@
 import%0A%0A
+from django import get_version%0A
 from dja
@@ -1113,9 +1113,45 @@
 __all__'
+ if get_version() %3E= '1.6' else None
 %0A

fix django 1.5 compatibility