# Path: lkdcourses/profiles/models.py
# class UserProfile(auth_models.AbstractUser):
#     address = models.TextField("Adres", blank=True, null=True)
#     phone = models.CharField("Telefon numarası", max_length=20, blank=True, null=True)
#     company = models.CharField(
#         "Çalıştığı şirket",
#         blank=True,
#         null=True,
#         help_text="Kamu çalışanları bağlı oldukları müdürlüğü yazabilir.",
#         max_length=255
#     )
#     tc_identifier = models.IntegerField("Tc kimlik numarası", blank=True, null=True)
#     public_officer = models.NullBooleanField("Kamu çalışanı", default=False, blank=True, null=True)
#     role = models.CharField("Bağlı olunan departman/bölüm", blank=True, null=True, max_length=255)
#     birthdate = models.DateField("Doğum tarihi", blank=True, null=True)
#     lkd_id = models.CharField("LKD üye numarası", blank=True, null=True, max_length=32)
#     inetd_id = models.CharField("INETD üye numarası", blank=True, null=True, max_length=32)
#     github_username = models.CharField("Github kullanıcı adı", max_length=64, blank=True, null=True)
# 
#     def __str__(self):
#         return smart_text(self.username)
# 
#     class Meta:
#         verbose_name = "Kullanıcı profili"
#         verbose_name_plural = "Kullanıcı profilleri"
# 
# Path: lkdcourses/profiles/mixins.py
# class LoginRequiredMixin(object):
# 
#     @classmethod
#     def as_view(cls):
#         return login_required(super(LoginRequiredMixin, cls).as_view())
# 
# Path: lkdcourses/profiles/forms.py
# class UserForm(ModelForm):
# 
#     class Meta:
#         model = UserProfile
#         exclude = [
#             'is_staff',
#             'is_active',
#             'date_joined',
#             'is_superuser',
#             'last_login',
#             'password',
#             'groups',
#             'user_permissions',
#             'username',
#         ]
# 
# class UserCreationForm(AuthModuleUserCreationForm):
# 
#     required_css_class = 'required'
# 
#     class Meta:
#         model = UserProfile
#         fields = ("username",)


from django.contrib import messages
from django.core.urlresolvers import reverse_lazy
from django.views.generic.edit import CreateView, UpdateView
from .models import UserProfile
from .mixins import LoginRequiredMixin
from .forms import (UserForm, UserCreationForm)
# -*- coding: utf-8 -*-

from __future__ import unicode_literals




class UserProfileUpdate(LoginRequiredMixin, UpdateView):
    model = UserProfile
    form_class = UserForm
    template_name = 'profiles/user_profile.html'
    success_url = reverse_lazy('profiles:profile_edit')
    success_message = 'Profiliniz başarıyla düzenlendi.'

    def get_object(self):
        return self.request.user

    def form_valid(self, form):
        messages.success(self.request, self.success_message)
        return super(UserProfileUpdate, self).form_valid(form)


class RegisterView(CreateView):
    form_class = UserCreationForm
    template_name = 'registration/register.html'
    success_url = '/'
    success_message = 'Kaydınız gerçekleştirildi. Lütfen giriş yapın.'

    def form_valid(self, form):
        messages.success(self.request, self.success_message)

# Path: lkdcourses/profiles/models.py
# class UserProfile(auth_models.AbstractUser):
#     address = models.TextField("Adres", blank=True, null=True)
#     phone = models.CharField("Telefon numarası", max_length=20, blank=True, null=True)
#     company = models.CharField(
#         "Çalıştığı şirket",
#         blank=True,
#         null=True,
#         help_text="Kamu çalışanları bağlı oldukları müdürlüğü yazabilir.",
#         max_length=255
#     )
#     tc_identifier = models.IntegerField("Tc kimlik numarası", blank=True, null=True)
#     public_officer = models.NullBooleanField("Kamu çalışanı", default=False, blank=True, null=True)
#     role = models.CharField("Bağlı olunan departman/bölüm", blank=True, null=True, max_length=255)
#     birthdate = models.DateField("Doğum tarihi", blank=True, null=True)
#     lkd_id = models.CharField("LKD üye numarası", blank=True, null=True, max_length=32)
#     inetd_id = models.CharField("INETD üye numarası", blank=True, null=True, max_length=32)
#     github_username = models.CharField("Github kullanıcı adı", max_length=64, blank=True, null=True)
# 
#     def __str__(self):
#         return smart_text(self.username)
# 
#     class Meta:
#         verbose_name = "Kullanıcı profili"
#         verbose_name_plural = "Kullanıcı profilleri"
# 
# Path: lkdcourses/profiles/mixins.py
# class LoginRequiredMixin(object):
# 
#     @classmethod
#     def as_view(cls):
#         return login_required(super(LoginRequiredMixin, cls).as_view())
# 
# Path: lkdcourses/profiles/forms.py
# class UserForm(ModelForm):
# 
#     class Meta:
#         model = UserProfile
#         exclude = [
#             'is_staff',
#             'is_active',
#             'date_joined',
#             'is_superuser',
#             'last_login',
#             'password',
#             'groups',
#             'user_permissions',
#             'username',
#         ]
# 
# class UserCreationForm(AuthModuleUserCreationForm):
# 
#     required_css_class = 'required'
# 
#     class Meta:
#         model = UserProfile
#         fields = ("username",)


# Path: lkdcourses/profiles/views.py
from django.contrib import messages
from django.core.urlresolvers import reverse_lazy
from django.views.generic.edit import CreateView, UpdateView
from .models import UserProfile
from .mixins import LoginRequiredMixin
from .forms import (UserForm, UserCreationForm)

# -*- coding: utf-8 -*-

from __future__ import unicode_literals




class UserProfileUpdate(LoginRequiredMixin, UpdateView):
    model = UserProfile
    form_class = UserForm
    template_name = 'profiles/user_profile.html'
    success_url = reverse_lazy('profiles:profile_edit')
    success_message = 'Profiliniz başarıyla düzenlendi.'

    def get_object(self):
        return self.request.user

    def form_valid(self, form):
        messages.success(self.request, self.success_message)
        return super(UserProfileUpdate, self).form_valid(form)


class RegisterView(CreateView):
    form_class = UserCreationForm
    template_name = 'registration/register.html'
    success_url = '/'
    success_message = 'Kaydınız gerçekleştirildi. Lütfen giriş yapın.'

    def form_valid(self, form):
        messages.success(self.request, self.success_message)

        return super(RegisterView, self).form_valid(form)