Esempio n. 1
0
 def save(self, *args, **kwargs):
     if self.slug is None:
         try:
             User.objects.get(username=self.username)
             # If the code above is reach on the block try, it means that
             # there is a duplicate
             self.username = uniquify_username(self.username)
         except User.DoesNotExist:
             pass
     self.slug = slugify(self.username)
     return super().save(*args, **kwargs)
Esempio n. 2
0
 def save(self, *args, **kwargs):
     if not self.creation_date:
         self.creation_date = datetime.datetime.utcnow()
     self.slug = slugify(self.title)
     is_new = not self.id
     # when new, the id must exist before extracting images
     if is_new:
         super(Article, self).save(*args, **kwargs)
     self.extract_images()
     self.title = Markup(self.title).striptags()
     self.content = clean_html(self.content, ALLOWED_TAGS)
     self.language = detect(self.content)
     return super(Article, self).save(*args, **kwargs)
Esempio n. 3
0
 def save(self, *args, **kwargs):
     self.slug = slugify(self.title)
     is_new = not self.id
     # when new, the id must exist before extracting images
     if is_new:
         super(Article, self).save(*args, **kwargs)
     self.extract_images()
     self.title = Markup(self.title).striptags()
     self.content = clean_html(self.content, ALLOWED_TAGS)
     self.language = detect(self.content)
     morph = self.morph()
     if self != morph:
         morph.pre_save(*args, **kwargs)
     return super(Article, self).save(*args, **kwargs)
Esempio n. 4
0
 def pre_save(self, *args, **kwargs):
     self.article.title = self.title
     self.article.publication_date = self.publication_date
     self.article.slug = slugify(self.title)