from django import forms
from django.contrib.auth.forms import (
    AuthenticationForm, UserCreationForm
)
from django.contrib.auth import get_user_model
from .models import User, Student, Society

User = User
Student = Student
Society = Society

class LoginForm(AuthenticationForm):
    """ログインフォーム"""

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for field in self.fields.values():
            field.widget.attrs['class'] = 'form-control'
            field.widget.attrs['placeholder'] = field.label  # placeholderにフィールドのラベルを入れる


class UserCreateForm(UserCreationForm):
    """ユーザー登録用フォーム"""

    class Meta:
        model = User
        fields = ('email',)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for field in self.fields.values():
            field.widget.attrs['class'] = 'form-control'

    def clean_email(self):
        email = self.cleaned_data['email']
        User.objects.filter(email=email, is_active=False).delete()
        return email

class StudentCreateForm(UserCreationForm):
    """ユーザー登録用フォーム"""

    class Meta:
        model = Student
        fields = ('email',)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for field in self.fields.values():
            field.widget.attrs['class'] = 'form-control'

    def clean_email(self):
        email = self.cleaned_data['email']
        User.objects.filter(email=email, is_active=False).delete()
        return email


class SocietyCreateForm(UserCreationForm):
    """サークル登録用フォーム"""

    class Meta:
        model = Society
        #model = Student
        fields = ('email',)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for field in self.fields.values():
            field.widget.attrs['class'] = 'form-control'

    def clean_email(self):
        email = self.cleaned_data['email']
        Society.objects.filter(email=email, is_active=False).delete()
        #Student.objects.filter(email=email, is_active=False).delete()
        return email

94f86012087d946df063b6438fd723bba6642e32
<mask token>


class StudentCreateForm(UserCreationForm):
    <mask token>


    class Meta:
        model = Student
        fields = 'email',
    <mask token>
    <mask token>


class SocietyCreateForm(UserCreationForm):
    """サークル登録用フォーム"""


    class Meta:
        model = Society
        fields = 'email',

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for field in self.fields.values():
            field.widget.attrs['class'] = 'form-control'

    def clean_email(self):
        email = self.cleaned_data['email']
        Society.objects.filter(email=email, is_active=False).delete()
        return email

<mask token>


class StudentCreateForm(UserCreationForm):
    <mask token>


    class Meta:
        model = Student
        fields = 'email',

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for field in self.fields.values():
            field.widget.attrs['class'] = 'form-control'

    def clean_email(self):
        email = self.cleaned_data['email']
        User.objects.filter(email=email, is_active=False).delete()
        return email


class SocietyCreateForm(UserCreationForm):
    """サークル登録用フォーム"""


    class Meta:
        model = Society
        fields = 'email',

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for field in self.fields.values():
            field.widget.attrs['class'] = 'form-control'

    def clean_email(self):
        email = self.cleaned_data['email']
        Society.objects.filter(email=email, is_active=False).delete()
        return email

<mask token>


class UserCreateForm(UserCreationForm):
    <mask token>


    class Meta:
        model = User
        fields = 'email',
    <mask token>
    <mask token>


class StudentCreateForm(UserCreationForm):
    """ユーザー登録用フォーム"""


    class Meta:
        model = Student
        fields = 'email',

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for field in self.fields.values():
            field.widget.attrs['class'] = 'form-control'

    def clean_email(self):
        email = self.cleaned_data['email']
        User.objects.filter(email=email, is_active=False).delete()
        return email


class SocietyCreateForm(UserCreationForm):
    """サークル登録用フォーム"""


    class Meta:
        model = Society
        fields = 'email',

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for field in self.fields.values():
            field.widget.attrs['class'] = 'form-control'

    def clean_email(self):
        email = self.cleaned_data['email']
        Society.objects.filter(email=email, is_active=False).delete()
        return email

<mask token>
User = User
Student = Student
Society = Society


class LoginForm(AuthenticationForm):
    """ログインフォーム"""

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for field in self.fields.values():
            field.widget.attrs['class'] = 'form-control'
            field.widget.attrs['placeholder'] = field.label


class UserCreateForm(UserCreationForm):
    """ユーザー登録用フォーム"""


    class Meta:
        model = User
        fields = 'email',

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for field in self.fields.values():
            field.widget.attrs['class'] = 'form-control'

    def clean_email(self):
        email = self.cleaned_data['email']
        User.objects.filter(email=email, is_active=False).delete()
        return email


class StudentCreateForm(UserCreationForm):
    """ユーザー登録用フォーム"""


    class Meta:
        model = Student
        fields = 'email',

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for field in self.fields.values():
            field.widget.attrs['class'] = 'form-control'

    def clean_email(self):
        email = self.cleaned_data['email']
        User.objects.filter(email=email, is_active=False).delete()
        return email


class SocietyCreateForm(UserCreationForm):
    """サークル登録用フォーム"""


    class Meta:
        model = Society
        fields = 'email',

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for field in self.fields.values():
            field.widget.attrs['class'] = 'form-control'

    def clean_email(self):
        email = self.cleaned_data['email']
        Society.objects.filter(email=email, is_active=False).delete()
        return email

from django import forms
from django.contrib.auth.forms import (
    AuthenticationForm, UserCreationForm
)
from django.contrib.auth import get_user_model
from .models import User, Student, Society

User = User
Student = Student
Society = Society

class LoginForm(AuthenticationForm):
    """ログインフォーム"""

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for field in self.fields.values():
            field.widget.attrs['class'] = 'form-control'
            field.widget.attrs['placeholder'] = field.label  # placeholderにフィールドのラベルを入れる


class UserCreateForm(UserCreationForm):
    """ユーザー登録用フォーム"""

    class Meta:
        model = User
        fields = ('email',)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for field in self.fields.values():
            field.widget.attrs['class'] = 'form-control'

    def clean_email(self):
        email = self.cleaned_data['email']
        User.objects.filter(email=email, is_active=False).delete()
        return email

class StudentCreateForm(UserCreationForm):
    """ユーザー登録用フォーム"""

    class Meta:
        model = Student
        fields = ('email',)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for field in self.fields.values():
            field.widget.attrs['class'] = 'form-control'

    def clean_email(self):
        email = self.cleaned_data['email']
        User.objects.filter(email=email, is_active=False).delete()
        return email


class SocietyCreateForm(UserCreationForm):
    """サークル登録用フォーム"""

    class Meta:
        model = Society
        #model = Student
        fields = ('email',)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for field in self.fields.values():
            field.widget.attrs['class'] = 'form-control'

    def clean_email(self):
        email = self.cleaned_data['email']
        Society.objects.filter(email=email, is_active=False).delete()
        #Student.objects.filter(email=email, is_active=False).delete()
        return email
