Mercurial > public > sg101
diff gpp/forums/models.py @ 285:8fd4984d5c3b
This is a first rough commit for #95, adding the ability to embed YouTube videos in forum posts. Some more polish and testing needs to happen at this point. I wanted to get all these changes off my hard drive and into the repository.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 14 Oct 2010 02:39:35 +0000 |
parents | d424b8bae71d |
children | c92fb89dbc7d |
line wrap: on
line diff
--- a/gpp/forums/models.py Mon Oct 04 01:01:29 2010 +0000 +++ b/gpp/forums/models.py Thu Oct 14 02:39:35 2010 +0000 @@ -8,6 +8,7 @@ from django.contrib.auth.models import User, Group from core.markup import site_markup +from oembed.models import Oembed class Category(models.Model): @@ -248,6 +249,7 @@ body = models.TextField() html = models.TextField() user_ip = models.IPAddressField(blank=True, default='', null=True) + attachments = models.ManyToManyField(Oembed, through='Attachment') class Meta: ordering = ('creation_date', ) @@ -365,3 +367,18 @@ def touch(self): self.last_visit = datetime.datetime.now() + +class Attachment(models.Model): + """ + This model is a "through" table for the M2M relationship between forum + posts and Oembed objects. + """ + post = models.ForeignKey(Post) + embed = models.ForeignKey(Oembed) + order = models.IntegerField() + + class Meta: + ordering = ('order', ) + + def __unicode__(self): + return u'Post %d, %s' % (self.post.pk, self.embed.title)