# Path: video/models.py
# class Video(BaseContentModel):
#     video_at_top = models.BooleanField(
#         "Put video at top",
#         default=False,
#         help_text="""
#             If checked, the video will appear preceding the body
#             of any related content instead of following.
#             """
#     )
#     url = models.CharField(
#         max_length=200,
#         blank=True,
#         help_text=""""
#             Acceptable sources are Youtube, Vimeo and Ustream.
#             Please give the link URL, not the embed code.
#             """
#     )
#     hide_info = models.BooleanField(
#         "Hide title and description",
#         default=False,
#         help_text="""
#             If checked, the video title and description will not be shown.
#             Left unchecked, the video will attempt to display the title and description
#             from the video source.
#             """
#     )
# 
#     content_type = models.ForeignKey(
#         ContentType,
#         on_delete=models.CASCADE,
#         blank=True,
#         null=True
#     )
#     object_id = models.PositiveIntegerField(blank=True, null=True)
#     content_object = GenericForeignKey()
# 
#     key = models.CharField(max_length=20, blank=True, editable=False)
#     source = models.CharField(max_length=20, blank=True, editable=False)
#     embed_src = models.CharField(max_length=200, blank=True, editable=False)
#     thumb_url = models.CharField(max_length=200, blank=True, editable=False)
# 
#     # Managers
#     objects = VideoManager()
#     pub_objects = PublishedVideoManager()
# 
#     def __str__(self):
#         return '{}: {}'.format(self.source, self.title)
# 
#     def get_absolute_url(self):
#         return reverse('video_detail', args=(self.slug,))
# 
#     def save(self, *args, **kwargs):
#         if self.title and not self.slug:
#             self.slug = slugify(self.title)
#         if not self.embed_src:
#             if 'youtube.com/watch' in self.url or 'youtu.be/' in self.url:
#                 self = get_youtube_data(self)
# 
#             if 'vimeo.com/' in self.url:
#                 self = get_vimeo_data(self)
# 
#             if 'ustream.tv/' in self.url:
#                 self = get_ustream_data(self)
# 
#         if self.key and self.embed_src:
#             self.embed_src = """
#                 <iframe src="{}{}" height="360" width="100%%"></iframe>
#                 """.format(self.embed_src, self.key)
#         super(Video, self).save()
# 
#     def get_image(self):
#         return self.thumb_url
# 
# class VideoGallery(models.Model):
#     title = models.CharField(max_length=200)
#     slug = models.SlugField(
#         max_length=200,
#         help_text="Used for URLs. Will auto-fill, but can be edited with caution."
#     )
#     gallery_credit = models.CharField(max_length=200, blank=True)
#     summary = models.TextField(blank=True)
#     featured = models.BooleanField(default=False)
#     created = models.DateTimeField(auto_now_add=True)
#     published = models.BooleanField(default=True)
#     video_collection = models.ManyToManyField(Video)
# 
#     class Meta:
#         verbose_name_plural = "video galleries"
# 
#     def __str__(self):
#         return self.title
# 
#     def get_absolute_url(self):
#         return reverse('video_gallery_detail', args=(self.slug,))


from django.conf import settings
from django.views.generic import ListView, DetailView
from video.models import Video, VideoGallery


paginate_by = getattr(settings, "PAGINATE_BY", 25)


class VideoList(ListView):
    """
    Returns a list of all videos.
    """
    template_name = 'video/video_list.html'
    paginate_by = paginate_by
    model = Video
video_list = VideoList.as_view()


class VideoDetail(DetailView):
    """
    Returns a video detail
    """
    template_name = 'video/video_detail.html'

# Path: video/models.py
# class Video(BaseContentModel):
#     video_at_top = models.BooleanField(
#         "Put video at top",
#         default=False,
#         help_text="""
#             If checked, the video will appear preceding the body
#             of any related content instead of following.
#             """
#     )
#     url = models.CharField(
#         max_length=200,
#         blank=True,
#         help_text=""""
#             Acceptable sources are Youtube, Vimeo and Ustream.
#             Please give the link URL, not the embed code.
#             """
#     )
#     hide_info = models.BooleanField(
#         "Hide title and description",
#         default=False,
#         help_text="""
#             If checked, the video title and description will not be shown.
#             Left unchecked, the video will attempt to display the title and description
#             from the video source.
#             """
#     )
# 
#     content_type = models.ForeignKey(
#         ContentType,
#         on_delete=models.CASCADE,
#         blank=True,
#         null=True
#     )
#     object_id = models.PositiveIntegerField(blank=True, null=True)
#     content_object = GenericForeignKey()
# 
#     key = models.CharField(max_length=20, blank=True, editable=False)
#     source = models.CharField(max_length=20, blank=True, editable=False)
#     embed_src = models.CharField(max_length=200, blank=True, editable=False)
#     thumb_url = models.CharField(max_length=200, blank=True, editable=False)
# 
#     # Managers
#     objects = VideoManager()
#     pub_objects = PublishedVideoManager()
# 
#     def __str__(self):
#         return '{}: {}'.format(self.source, self.title)
# 
#     def get_absolute_url(self):
#         return reverse('video_detail', args=(self.slug,))
# 
#     def save(self, *args, **kwargs):
#         if self.title and not self.slug:
#             self.slug = slugify(self.title)
#         if not self.embed_src:
#             if 'youtube.com/watch' in self.url or 'youtu.be/' in self.url:
#                 self = get_youtube_data(self)
# 
#             if 'vimeo.com/' in self.url:
#                 self = get_vimeo_data(self)
# 
#             if 'ustream.tv/' in self.url:
#                 self = get_ustream_data(self)
# 
#         if self.key and self.embed_src:
#             self.embed_src = """
#                 <iframe src="{}{}" height="360" width="100%%"></iframe>
#                 """.format(self.embed_src, self.key)
#         super(Video, self).save()
# 
#     def get_image(self):
#         return self.thumb_url
# 
# class VideoGallery(models.Model):
#     title = models.CharField(max_length=200)
#     slug = models.SlugField(
#         max_length=200,
#         help_text="Used for URLs. Will auto-fill, but can be edited with caution."
#     )
#     gallery_credit = models.CharField(max_length=200, blank=True)
#     summary = models.TextField(blank=True)
#     featured = models.BooleanField(default=False)
#     created = models.DateTimeField(auto_now_add=True)
#     published = models.BooleanField(default=True)
#     video_collection = models.ManyToManyField(Video)
# 
#     class Meta:
#         verbose_name_plural = "video galleries"
# 
#     def __str__(self):
#         return self.title
# 
#     def get_absolute_url(self):
#         return reverse('video_gallery_detail', args=(self.slug,))


# Path: video/views.py
from django.conf import settings
from django.views.generic import ListView, DetailView
from video.models import Video, VideoGallery



paginate_by = getattr(settings, "PAGINATE_BY", 25)


class VideoList(ListView):
    """
    Returns a list of all videos.
    """
    template_name = 'video/video_list.html'
    paginate_by = paginate_by
    model = Video
video_list = VideoList.as_view()


class VideoDetail(DetailView):
    """
    Returns a video detail
    """
    template_name = 'video/video_detail.html'

    model = Video