# Path: emaula/lessons/models.py
# class Text(models.Model):
#     """
#     TODO: WYSIWYG
#     """
#     classroom = models.ForeignKey(Classroom,
#                                   related_name='text',
#                                   on_delete=models.SET_NULL,
#                                   blank=True,
#                                   null=True)
# 
#     title = models.CharField('Título', max_length=200)
#     text = models.TextField('Texto', blank=True)
#     source = models.URLField('Link para a fonte', blank=True)
# 
#     def __str__(self):
#         return self.title
# 
# class Link(models.Model):
# 
#     classroom = models.ForeignKey(Classroom,
#                                   related_name='link',
#                                   on_delete=models.SET_NULL,
#                                   blank=True,
#                                   null=True)
# 
#     url = models.URLField()
#     name = models.CharField('Nome', max_length=600, blank=True)
#     access_date = models.DateField('Data de acesso')
# 
#     def __str__(self):
#         return '{0} - {1}'.format(self.name, self.url)
# 
# class Image(models.Model):
# 
#     classroom = models.ForeignKey(Classroom,
#                                   related_name='image',
#                                   on_delete=models.SET_NULL,
#                                   blank=True,
#                                   null=True)
# 
#     image_path = models.ImageField('Endereço da imagem',
#                                    upload_to='media',
#                                    default='pic_folder/user/no-img.jpg')
#     alt = models.CharField('Texto alternativo',
#                            max_length=1200,
#                            blank=True)
# 
#     def __str__(self):
#         return self.image_path.name
# 
# class Video(models.Model):
# 
#     classroom = models.ForeignKey(Classroom,
#                                   related_name='video',
#                                   on_delete=models.SET_NULL,
#                                   blank=True,
#                                   null=True)
# 
#     video = EmbedVideoField('Endereço do Youtube')
#     title = models.CharField('Título do vídeo',
#                              max_length=1200,
#                              blank=True)
# 
#     def __str__(self):
#         return '{0} - {1}'.format(self.title, self.video)
# 
# class Audio(models.Model):
# 
#     classroom = models.ForeignKey(Classroom,
#                                   related_name='audio',
#                                   on_delete=models.SET_NULL,
#                                   blank=True,
#                                   null=True)
# 
#     audio = EmbedVideoField('Endereço do SoundCloud')
#     title = models.CharField('Título do áudio',
#                              max_length=1200,
#                              blank=True)
# 
#     def __str__(self):
#         return '{0} - {1}'.format(self.title, self.audio)


from django.shortcuts import render, get_object_or_404
from django.views import generic
from .models import Text, Link, Image, Video, Audio

    def get_queryset(self):
        return Link.objects.all()


class ImageListView(generic.ListView):
    model = Image

    def get_queryset(self):
        return Image.objects.all()


class AudioListView(generic.ListView):
    model = Audio

    def get_queryset(self):
        return Audio.objects.all()


class VideoListView(generic.ListView):
    model = Video

    def get_queryset(self):
        return Video.objects.all()


class TextDetailView(generic.DetailView):
    model = Text

    def text_detail(request, pk):

# Path: emaula/lessons/models.py
# class Text(models.Model):
#     """
#     TODO: WYSIWYG
#     """
#     classroom = models.ForeignKey(Classroom,
#                                   related_name='text',
#                                   on_delete=models.SET_NULL,
#                                   blank=True,
#                                   null=True)
# 
#     title = models.CharField('Título', max_length=200)
#     text = models.TextField('Texto', blank=True)
#     source = models.URLField('Link para a fonte', blank=True)
# 
#     def __str__(self):
#         return self.title
# 
# class Link(models.Model):
# 
#     classroom = models.ForeignKey(Classroom,
#                                   related_name='link',
#                                   on_delete=models.SET_NULL,
#                                   blank=True,
#                                   null=True)
# 
#     url = models.URLField()
#     name = models.CharField('Nome', max_length=600, blank=True)
#     access_date = models.DateField('Data de acesso')
# 
#     def __str__(self):
#         return '{0} - {1}'.format(self.name, self.url)
# 
# class Image(models.Model):
# 
#     classroom = models.ForeignKey(Classroom,
#                                   related_name='image',
#                                   on_delete=models.SET_NULL,
#                                   blank=True,
#                                   null=True)
# 
#     image_path = models.ImageField('Endereço da imagem',
#                                    upload_to='media',
#                                    default='pic_folder/user/no-img.jpg')
#     alt = models.CharField('Texto alternativo',
#                            max_length=1200,
#                            blank=True)
# 
#     def __str__(self):
#         return self.image_path.name
# 
# class Video(models.Model):
# 
#     classroom = models.ForeignKey(Classroom,
#                                   related_name='video',
#                                   on_delete=models.SET_NULL,
#                                   blank=True,
#                                   null=True)
# 
#     video = EmbedVideoField('Endereço do Youtube')
#     title = models.CharField('Título do vídeo',
#                              max_length=1200,
#                              blank=True)
# 
#     def __str__(self):
#         return '{0} - {1}'.format(self.title, self.video)
# 
# class Audio(models.Model):
# 
#     classroom = models.ForeignKey(Classroom,
#                                   related_name='audio',
#                                   on_delete=models.SET_NULL,
#                                   blank=True,
#                                   null=True)
# 
#     audio = EmbedVideoField('Endereço do SoundCloud')
#     title = models.CharField('Título do áudio',
#                              max_length=1200,
#                              blank=True)
# 
#     def __str__(self):
#         return '{0} - {1}'.format(self.title, self.audio)


# Path: emaula/lessons/views.py
from django.shortcuts import render, get_object_or_404
from django.views import generic
from .models import Text, Link, Image, Video, Audio


    def get_queryset(self):
        return Link.objects.all()


class ImageListView(generic.ListView):
    model = Image

    def get_queryset(self):
        return Image.objects.all()


class AudioListView(generic.ListView):
    model = Audio

    def get_queryset(self):
        return Audio.objects.all()


class VideoListView(generic.ListView):
    model = Video

    def get_queryset(self):
        return Video.objects.all()


class TextDetailView(generic.DetailView):
    model = Text

    def text_detail(request, pk):

        text = get_object_or_404(Text, pk=pk)