Ejemplo n.º 1
0
class Post(models.Model):
    """
    A feed contains a collection of posts. This model stores them.
    """
    feed = models.ForeignKey("planet.Feed", null=False, blank=False, on_delete=models.CASCADE)
    title = models.CharField(_("Title"), max_length=255, db_index=True)
    authors = models.ManyToManyField("planet.Author", through=PostAuthorData)
    url = models.URLField(_("Url"), max_length=1000, db_index=True)
    guid = models.CharField(_("Guid"), max_length=32, db_index=True)
    content = models.TextField(_("Content"))
    comments_url = models.URLField(_("Comments URL"), blank=True, null=True)

    date_modified = models.DateTimeField(_("Date modified"), null=True,
        blank=True, db_index=True)
    date_created = models.DateTimeField(_("Date created"), auto_now_add=True)

    site_objects = PostManager()
    objects = models.Manager()

    class Meta:
        verbose_name = _("Post")
        verbose_name_plural = _("Posts")
        ordering = ('-date_created', '-date_modified')
        unique_together = (('feed', 'guid'),)

    def __str__(self):
        return "{} [{}]".format(self.title, self.feed.title)

    def get_absolute_url(self):
        return reverse('planet_post_detail', args=[str(self.id), self.get_slug()])

    def get_slug(self):
        return slugify(self.title) or "no-title"
Ejemplo n.º 2
0
class Post(models.Model):
    """
    A feed contains a collection of posts. This model stores them.
    """
    feed = models.ForeignKey("planet.Feed", null=False, blank=False)
    title = models.CharField(_("Title"), max_length=255, db_index=True)
    authors = models.ManyToManyField("planet.Author", through=PostAuthorData)
    url = models.URLField(_("Url"), max_length=1000, db_index=True)
    guid = models.TextField(_("Guid"), db_index=True)
    content = models.TextField(_("Content"))
    comments_url = models.URLField(_("Comments URL"), blank=True, null=True)

    date_modified = models.DateTimeField(_("Date modified"),
                                         null=True,
                                         blank=True,
                                         db_index=True)
    date_created = models.DateTimeField(_("Date created"), auto_now_add=True)

    site_objects = PostManager()
    objects = models.Manager()

    class Meta:
        verbose_name = _("Post")
        verbose_name_plural = _("Posts")
        ordering = ('-date_created', '-date_modified')
        unique_together = (('feed', 'guid'), )

    def __unicode__(self):
        return u"%s [%s]" % (self.title, self.feed.title)

    @models.permalink
    def get_absolute_url(self):
        return ('planet.views.post_detail', [str(self.id)])
Ejemplo n.º 3
0
class Post(models.Model):
    """
    A feed contains a collection of posts. This model stores them.
    """
    feed = models.ForeignKey("planet.Feed",
                             null=False,
                             blank=False,
                             related_name='posts')
    title = models.CharField(_("Title"), max_length=255, db_index=True)
    authors = models.ManyToManyField("planet.Author", through=PostAuthorData)
    url = models.URLField(_("Url"), max_length=255, db_index=True)
    image_url = models.URLField(_("Url"),
                                max_length=255,
                                db_index=True,
                                null=True)
    guid = models.CharField(_("Guid"), max_length=32, db_index=True, null=True)
    content = models.TextField(_("Content"))
    comments_url = models.URLField(_("Comments URL"), blank=True, null=True)

    date_modified = models.DateTimeField(_("Date modified"),
                                         null=True,
                                         blank=True,
                                         db_index=True)
    date_created = models.DateTimeField(_("Date created"), auto_now_add=True)
    cluster_id = models.IntegerField(null=True)
    rank = models.IntegerField(null=True)
    myvector = models.TextField(_("MyVector"), null=True)
    site_objects = PostManager()
    objects = models.Manager()
    # ADDITION OVER HERE
    category = models.ForeignKey(Category,
                                 blank=True,
                                 null=True,
                                 db_index=True,
                                 related_name='categories')

    class Meta:
        verbose_name = _("Post")
        verbose_name_plural = _("Posts")
        ordering = ('-date_created', '-date_modified')
        unique_together = (('feed', 'guid'), )

    def __str__(self):
        return "{} [{}]".format(self.title, self.feed.title)

    @models.permalink
    def get_absolute_url(self):
        return ('planet.views.post_detail', [str(self.id), self.get_slug()])

    def get_slug(self):
        return slugify(self.title) or "no-title"