# Path: startup/accounts/forms.py
# class UserCreationForm(forms.ModelForm):
#     """A form for creating new users. Includes all the required
#     fields, plus a repeated password."""
#     password1 = forms.CharField(label=_('Password'), widget=forms.PasswordInput)
#     password2 = forms.CharField(label=_('Password confirmation'), widget=forms.PasswordInput)
# 
#     class Meta:
#         model = User
#         fields = ('username', 'email', 'first_name', 'last_name')
# 
#     def clean_password2(self):
#         # Check that the two password entries match
#         password1 = self.cleaned_data.get("password1")
#         password2 = self.cleaned_data.get("password2")
#         if password1 and password2 and password1 != password2:
#             raise forms.ValidationError("Passwords don't match")
#         return password2
# 
#     def save(self, commit=True):
#         # Save the provided password in hashed format
#         user = super(UserCreationForm, self).save(commit=False)
#         user.set_password(self.cleaned_data["password1"])
#         if commit:
#             user.save()
#         return user
# 
# class UserUpdateForm(forms.ModelForm):
#     class Meta:
#         model = User
#         fields = ('username', 'email', 'first_name', 'last_name', 'photo')


from django.views.generic import DetailView, UpdateView, CreateView
from django.contrib.auth import get_user_model
from startup.accounts.forms import UserCreationForm, UserUpdateForm
# coding=utf-8




User = get_user_model()


class DetailUser(DetailView):
    model = User

    def get_object(self, queryset=None):
        return self.request.user


class CreateUser(CreateView):
    model = User

# Path: startup/accounts/forms.py
# class UserCreationForm(forms.ModelForm):
#     """A form for creating new users. Includes all the required
#     fields, plus a repeated password."""
#     password1 = forms.CharField(label=_('Password'), widget=forms.PasswordInput)
#     password2 = forms.CharField(label=_('Password confirmation'), widget=forms.PasswordInput)
# 
#     class Meta:
#         model = User
#         fields = ('username', 'email', 'first_name', 'last_name')
# 
#     def clean_password2(self):
#         # Check that the two password entries match
#         password1 = self.cleaned_data.get("password1")
#         password2 = self.cleaned_data.get("password2")
#         if password1 and password2 and password1 != password2:
#             raise forms.ValidationError("Passwords don't match")
#         return password2
# 
#     def save(self, commit=True):
#         # Save the provided password in hashed format
#         user = super(UserCreationForm, self).save(commit=False)
#         user.set_password(self.cleaned_data["password1"])
#         if commit:
#             user.save()
#         return user
# 
# class UserUpdateForm(forms.ModelForm):
#     class Meta:
#         model = User
#         fields = ('username', 'email', 'first_name', 'last_name', 'photo')


# Path: startup/accounts/views.py
from django.views.generic import DetailView, UpdateView, CreateView
from django.contrib.auth import get_user_model
from startup.accounts.forms import UserCreationForm, UserUpdateForm

# coding=utf-8




User = get_user_model()


class DetailUser(DetailView):
    model = User

    def get_object(self, queryset=None):
        return self.request.user


class CreateUser(CreateView):
    model = User

    form_class = UserCreationForm