view bns_website/videos/models.py @ 105:f3a275a53bc6

Use a local version of bootstrap 1.4.0. Twitter stopped hosting the version we were using.
author Brian Neal <bgneal@gmail.com>
date Tue, 15 Oct 2013 20:50:29 -0500
parents a0d3bc630ebd
children
line wrap: on
line source
"""
Models for the videos app.

"""
from django.db import models


# The whole purpose of this application is to shuffle the videos in
# a YouTube playlist.
#
# We'd like to embed a video player to show videos from all the bands that
# participated in the compilation. So we create a YouTube playlist with a long
# list of videos. YouTube no longer offers a way to shuffle the playlist via
# the embed code. Instead we will use the YouTube Javascript API to accomplish
# this. However, the Javascript API works off of video IDs. So we now need
# a way to obtain all the video IDs from a YouTube playlist. This model
# stores the playlist URL and an admin function can be run to retrieve the
# video ID list via the Python GData YouTube API. The video list is also
# stored in this model. The view function can then read the video ID list,
# randomize it, and give it to the template to build the appropriate 
# Javascript.

class Playlist(models.Model):
    """
    This model stores a YouTube playlist URL and a list of video IDs that
    make up the playlist.

    """
    playlist_title = models.CharField(max_length=128, blank=True)
    playlist_url = models.URLField()
    video_list = models.TextField(blank=True)
    sync_date = models.DateTimeField(null=True, blank=True)

    def __unicode__(self):
        if self.playlist_title:
            return self.playlist_title

        return u"(Please sync with YouTube to retrieve the videos)"