Exemple #1
0
    def save(self, force_insert=False, force_update=False, using=None, update_fields=None):

        assert (self.author is not None) ^ bool(self.author_name)

        if not self.id:
            self.slug = get_slug(Article, self.title)

            if self.author:
                if self.type == Article.ARTICLE:
                    self.author.articles_count += 1
                    self.author.save()
                elif self.type == Article.COMMENT:
                    self.author.comments_count += 1
                    self.author.save()

        r = super(Article, self).save(force_insert, force_update, using, update_fields)

        self.content, found = html.extract_images(self, self.content, ArticleImage)
        if found:
            return super(Article, self).save(force_update=True, using=using, update_fields=["content"])