# Path: companionpages/users/forms.py
# class UserForm(forms.ModelForm):
# 
#     class Meta:
#         # Set this form to use the User model.
#         model = User
# 
#         fields = ("first_name", "last_name", "public_name", "affiliation", "biography", "country")
# 
# Path: companionpages/users/models.py
# class User(AbstractUser):
#     # from AbstractUser we have
#     # firstname, lastname, email, username
# 
#     public_name = models.CharField(max_length=150, blank=True, verbose_name=_(u'Public Name'), help_text=_(u'Publically displayed name'))
#     biography = models.TextField(max_length=400, blank=True, verbose_name=_(u'Biography'))
#     affiliation = models.CharField(max_length=200, verbose_name=_(u'Affiliation'), blank=True)
#     country = models.CharField(max_length=200, verbose_name=_(u'Country'), blank=True)
#     urls = JSONField(default="{}", verbose_name=_(u'URLs'))
# 
#     def __unicode__(self):
#         return self.email


from django.core.urlresolvers import reverse
from django.views.generic import DetailView
from django.views.generic import RedirectView
from django.views.generic import UpdateView
from django.views.generic import ListView
from braces.views import LoginRequiredMixin, SelectRelatedMixin
from .forms import UserForm
from .models import User
# -*- coding: utf-8 -*-
# Import the reverse lookup function

# view imports




class UserDetailView(LoginRequiredMixin, SelectRelatedMixin, DetailView):
    model = User
    select_related = ['article__site_owner', 'contributor__user']

    def get_queryset(self):
        queryset = super(UserDetailView, self).get_queryset()
        return queryset.select_related(*self.select_related)


class UserRedirectView(LoginRequiredMixin, RedirectView):
    permanent = False

    def get_redirect_url(self):
        return reverse("users:detail", args=(self.request.user.id,))


class UserUpdateView(LoginRequiredMixin, UpdateView):


# Path: companionpages/users/forms.py
# class UserForm(forms.ModelForm):
# 
#     class Meta:
#         # Set this form to use the User model.
#         model = User
# 
#         fields = ("first_name", "last_name", "public_name", "affiliation", "biography", "country")
# 
# Path: companionpages/users/models.py
# class User(AbstractUser):
#     # from AbstractUser we have
#     # firstname, lastname, email, username
# 
#     public_name = models.CharField(max_length=150, blank=True, verbose_name=_(u'Public Name'), help_text=_(u'Publically displayed name'))
#     biography = models.TextField(max_length=400, blank=True, verbose_name=_(u'Biography'))
#     affiliation = models.CharField(max_length=200, verbose_name=_(u'Affiliation'), blank=True)
#     country = models.CharField(max_length=200, verbose_name=_(u'Country'), blank=True)
#     urls = JSONField(default="{}", verbose_name=_(u'URLs'))
# 
#     def __unicode__(self):
#         return self.email


# Path: companionpages/users/views.py
from django.core.urlresolvers import reverse
from django.views.generic import DetailView
from django.views.generic import RedirectView
from django.views.generic import UpdateView
from django.views.generic import ListView
from braces.views import LoginRequiredMixin, SelectRelatedMixin
from .forms import UserForm
from .models import User

# -*- coding: utf-8 -*-
# Import the reverse lookup function

# view imports




class UserDetailView(LoginRequiredMixin, SelectRelatedMixin, DetailView):
    model = User
    select_related = ['article__site_owner', 'contributor__user']

    def get_queryset(self):
        queryset = super(UserDetailView, self).get_queryset()
        return queryset.select_related(*self.select_related)


class UserRedirectView(LoginRequiredMixin, RedirectView):
    permanent = False

    def get_redirect_url(self):
        return reverse("users:detail", args=(self.request.user.id,))


class UserUpdateView(LoginRequiredMixin, UpdateView):


    form_class = UserForm