class VideoCategory(pr_models.PRModel):
    video = pr_models.PRForeignKey(Video,
                                   related_name='category_relationships')
    category = pr_models.PRForeignKey(Category,
                                      related_name='video_relationships')
    STATUS_CHOICES = [
        ('pending', 'pending'),
        ('approved', 'approved'),
        ('rejected', 'rejected'),
    ]
    status = models.CharField(max_length=15,
                              choices=STATUS_CHOICES,
                              default='pending')

    def validate(self, validation_errors=None):
        if validation_errors is None:
            validation_errors = dict()
        if not self.id and self.category.locked:
            if not validation_errors.has_key('category'):
                validation_errors['category'] = list()
            validation_errors['category'].append(
                u"Can't add Video to locked Category")
        return super(VideoCategory, self).validate(validation_errors)

    @property
    def category_name(self):
        return self.category.name

    def __unicode__(self):
        return '%s : %s' % (self.video, self.category)

    class Meta:
        ordering = ('id', )
        unique_together = ('video', 'category')
class EncodedVideo(pr_models.OwnedPRModel):
    """This is a user Task to view a video."""

    #: used to make the encoding.com job request
    audio_codec = models.CharField(max_length=31, null=False)
    #: The bitrate of the EncodedVideo, in kilobytes per second
    bitrate = models.CharField(max_length=31, null=False)
    #: used to make the encoding.com job request
    output = models.CharField(max_length=31)
    #: used to make the encoding.com job request
    size = models.CharField(max_length=15)
    #: The video that this encoding is for
    video = pr_models.PRForeignKey(Video,
                                   null=False,
                                   related_name='encoded_videos')
    # Different codecs can result in different stream URLs,
    # so capture the codec for when those URLs are generated
    video_codec = models.CharField(max_length=31)
    #: Represents the encoded video stored in S3
    file = models.FileField(upload_to='video/', storage=S3BotoStorage())

    @property
    def http_url(self):
        if self.file.name:
            return self.file.url

    @property
    def url(self):
        if self.file.name:
            return awsutils.CloudFrontStreamingObject(
                self.file.name).generate_url()

    class Meta:
        ordering = ('id', )
Exemple #3
0
class Order(pr_models.OwnedPRModel):
    #: the User's last name / surname
    last_name = models.CharField(max_length=31)
    #: the User's first name / given name / Christian name
    first_name = models.CharField(max_length=31)
    email = models.EmailField()
    phone = models.CharField(max_length=31, null=True)
    #: country (two letter ISO code, e.g. us, fi, de, jp, cn)
    country = models.CharField(max_length=2)
    #: state in the US
    region = models.CharField(max_length=31)
    #: city in the US
    locality = models.CharField(max_length=31)
    #: zip code in the US
    postal_code = models.CharField(max_length=16)
    #: all Address lines above the locality but below a person's name
    label = models.CharField(max_length=255)
    created = models.DateTimeField(auto_now_add=True)
    sent = models.DateTimeField(null=True)
    confirmation_code = models.CharField(max_length=31, null=True)
    shipment_method = pr_models.PRForeignKey('ShipmentMethod',
                                             related_name='orders')
Exemple #4
0
class LineItem(pr_models.OwnedPRModel):
    sku = models.CharField(max_length=31)
    quantity = models.PositiveSmallIntegerField()
    order = pr_models.PRForeignKey('Order', related_name='line_items')
Exemple #5
0
class Forum(models.Model):
    categories = models.ManyToManyField('ForumCategory', related_name='forums')
    name = models.CharField(max_length=127, unique=True)
    description = models.TextField()
    blame = pr_models.PRForeignKey(pr_models.Blame)
Exemple #6
0
class ForumCategory(models.Model):
    name = models.CharField(max_length=127, unique=True)
    blame = pr_models.PRForeignKey(pr_models.Blame)
Exemple #7
0
class ForumPostAttachment(models.Model):
    post = pr_models.PRForeignKey('ForumPost', related_name='attachments')
    name = models.CharField(max_length=255)
    description = models.TextField()
    attachment = models.FileField(upload_to='forum')
Exemple #8
0
class ForumPost(models.Model):
    user = pr_models.PRForeignKey(pr_models.User, related_name='posts')
    topic = pr_models.PRForeignKey('ForumTopic', related_name='posts')
    body = models.TextField()
    blame = pr_models.PRForeignKey(pr_models.Blame)
Exemple #9
0
class ForumTopic(models.Model):
    forum = pr_models.PRForeignKey('Forum', related_name='topics')
    name = models.CharField(max_length=127)
    sticky = pr_models.PRBooleanField(default=False)
    closed = pr_models.PRBooleanField(default=False)
    blame = pr_models.PRForeignKey(pr_models.Blame)