# Path: radioco/apps/programmes/models.py
# class Role(models.Model):
#     person = models.ForeignKey(User, verbose_name=_("person"), on_delete=models.CASCADE)
#     programme = models.ForeignKey(Programme, verbose_name=_("programme"), on_delete=models.CASCADE)
#     role = models.CharField(max_length=60, blank=True, null=True, verbose_name=_("role"))
#     description = models.TextField(blank=True, verbose_name=_("description"))
#     date_joined = models.DateField(auto_now_add=True)
# 
#     class Meta:
#         unique_together = ('person', 'programme')
#         verbose_name = _('role')
#         verbose_name_plural = _('roles')
#         permissions = (
#             ("see_all_roles", "Can see all roles"),
#         )
# 
#     def __str__(self):
#         return "%s: %s" % (self.programme.name, self.person.username)
# 
# Path: radioco/apps/users/models.py
# class UserProfile(models.Model):
#     user = models.OneToOneField(User, unique=True)
#     bio = RichTextUploadingField(blank=True, verbose_name=_("biography"))
#     avatar = models.ImageField(
#         upload_to='avatars/', default='defaults/default-userprofile-avatar.jpg', verbose_name=_("avatar")
#     )
#     display_personal_page = models.BooleanField(default=False, verbose_name=_("display personal page"))
#     slug = models.SlugField(max_length=30)
# 
#     def get_absolute_url(self):
#         return reverse('users:detail', args=[self.slug])
# 
#     def save(self, *args, **kwargs):
#         if not self.pk:
#             try:
#                 p = UserProfile.objects.get(user=self.user)
#                 self.pk = p.pk
#             except UserProfile.DoesNotExist:
#                 pass
#         self.slug = slugify(self.user.username)
#         super(UserProfile, self).save(*args, **kwargs)
# 
#     class Meta:
#         default_permissions = ('change',)
#         verbose_name = _('user profile')
#         verbose_name_plural = _('user profile')
# 
#     def __str__(self):
#         return "%s's profile" % self.user


from django.shortcuts import render, get_object_or_404
from django.views import generic
from radioco.apps.programmes.models import Role
from radioco.apps.users.models import UserProfile
# Radioco - Broadcasting Radio Recording Scheduling system.
# Copyright (C) 2014  Iago Veloso Abalo
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.





class UsersView(generic.ListView):
    model = UserProfile

    def get_queryset(self):

# Path: radioco/apps/programmes/models.py
# class Role(models.Model):
#     person = models.ForeignKey(User, verbose_name=_("person"), on_delete=models.CASCADE)
#     programme = models.ForeignKey(Programme, verbose_name=_("programme"), on_delete=models.CASCADE)
#     role = models.CharField(max_length=60, blank=True, null=True, verbose_name=_("role"))
#     description = models.TextField(blank=True, verbose_name=_("description"))
#     date_joined = models.DateField(auto_now_add=True)
# 
#     class Meta:
#         unique_together = ('person', 'programme')
#         verbose_name = _('role')
#         verbose_name_plural = _('roles')
#         permissions = (
#             ("see_all_roles", "Can see all roles"),
#         )
# 
#     def __str__(self):
#         return "%s: %s" % (self.programme.name, self.person.username)
# 
# Path: radioco/apps/users/models.py
# class UserProfile(models.Model):
#     user = models.OneToOneField(User, unique=True)
#     bio = RichTextUploadingField(blank=True, verbose_name=_("biography"))
#     avatar = models.ImageField(
#         upload_to='avatars/', default='defaults/default-userprofile-avatar.jpg', verbose_name=_("avatar")
#     )
#     display_personal_page = models.BooleanField(default=False, verbose_name=_("display personal page"))
#     slug = models.SlugField(max_length=30)
# 
#     def get_absolute_url(self):
#         return reverse('users:detail', args=[self.slug])
# 
#     def save(self, *args, **kwargs):
#         if not self.pk:
#             try:
#                 p = UserProfile.objects.get(user=self.user)
#                 self.pk = p.pk
#             except UserProfile.DoesNotExist:
#                 pass
#         self.slug = slugify(self.user.username)
#         super(UserProfile, self).save(*args, **kwargs)
# 
#     class Meta:
#         default_permissions = ('change',)
#         verbose_name = _('user profile')
#         verbose_name_plural = _('user profile')
# 
#     def __str__(self):
#         return "%s's profile" % self.user


# Path: radioco/apps/users/views.py
from django.shortcuts import render, get_object_or_404
from django.views import generic
from radioco.apps.programmes.models import Role
from radioco.apps.users.models import UserProfile

# Radioco - Broadcasting Radio Recording Scheduling system.
# Copyright (C) 2014  Iago Veloso Abalo
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.





class UsersView(generic.ListView):
    model = UserProfile

    def get_queryset(self):

        return UserProfile.objects.filter(display_personal_page=True).select_related('user')