Ejemplo n.º 1
0
                stored_oembed = StoredOEmbed.objects.filter(
                        match=instance.url)[0]
                return stored_oembed
        except:
            pass

    def __set__(self, instance, value):
        raise NotImplementedError('%s is read-only' % self.name)


class AggregateMedia(models.Model):
    url = models.TextField()
    object_id = models.IntegerField(blank=True, null=True)
    content_type = models.ForeignKey(ContentType, blank=True, null=True,
            related_name="aggregate_media")
    content_object = GenericForeignKey()
    
    media = AggregateMediaDescriptor()
    
    def __unicode__(self):
        return self.url
    
    def get_absolute_url(self):
        if self.content_object and hasattr(self.content_object, 'get_absolute_url'):
            return self.content_object.get_absolute_url()
        return self.url


from oembed.listeners import start_listening
start_listening()
Ejemplo n.º 2
0
        except:
            pass

    def __set__(self, instance, value):
        raise NotImplementedError('%s is read-only' % self.name)


class AggregateMedia(models.Model):
    url = models.TextField()
    object_id = models.IntegerField(blank=True, null=True)
    content_type = models.ForeignKey(ContentType,
                                     blank=True,
                                     null=True,
                                     related_name="aggregate_media")
    content_object = GenericForeignKey()

    media = AggregateMediaDescriptor()

    def __unicode__(self):
        return self.url

    def get_absolute_url(self):
        if self.content_object and hasattr(self.content_object,
                                           'get_absolute_url'):
            return self.content_object.get_absolute_url()
        return self.url


from oembed.listeners import start_listening
start_listening()