def save(self, *args, **kwargs): _, is_clean = self._based_on_is_clean() if not is_clean: # No more Mister Nice Guy # TODO(erik): This error message ignores non-translations. raise ProgrammingError('Revision.based_on must be None or refer ' 'to a revision of the default-' 'language document.') if self.content: self.content = (wiki.content .parse(self.content) .injectSectionIDs() .serialize()) if not self.title: self.title = self.document.title if not self.slug: self.slug = self.document.slug super(Revision, self).save(*args, **kwargs) # When a revision is approved, update document metadata and re-cache # the document's html content if self.is_approved and ( not self.document.current_revision or self.document.current_revision.id < self.id): self.document.title = self.title self.document.slug = self.slug self.document.html = self.content_cleaned self.document.current_revision = self self.document.save()
def save(self, *args, **kwargs): _, is_clean = self._based_on_is_clean() if not is_clean: # No more Mister Nice Guy # TODO(erik): This error message ignores non-translations. raise ProgrammingError('Revision.based_on must be None or refer ' 'to a revision of the default-' 'language document.') super(Revision, self).save(*args, **kwargs) # When a revision is approved, re-cache the document's html content if self.is_approved and (not self.document.current_revision or self.document.current_revision.id < self.id): self.document.html = self.content_parsed self.document.current_revision = self self.document.save()
def save(self, *args, **kwargs): _, is_clean = self._based_on_is_clean() if not is_clean: # No more Mister Nice Guy # TODO(erik): This error message ignores non-translations. raise ProgrammingError('Revision.based_on must be None or refer ' 'to a revision of the default-' 'language document.') super(Revision, self).save(*args, **kwargs) # When a revision is approved, re-cache the document's html content # and update document contributors if self.is_approved and ( not self.document.current_revision or self.document.current_revision.id < self.id): # Determine if there are new contributors and add them to the list contributors = self.document.contributors.all() # Exclude all explicitly rejected revisions new_revs = self.document.revisions.exclude( reviewed__isnull=False, is_approved=False) if self.document.current_revision: new_revs = new_revs.filter( id__gt=self.document.current_revision.id) new_contributors = set([r.creator for r in new_revs.select_related('creator')]) for user in new_contributors: if user not in contributors: self.document.contributors.add(user) # Update document denormalized fields if self.is_ready_for_localization: self.document.latest_localizable_revision = self self.document.html = self.content_parsed self.document.current_revision = self self.document.save() elif (self.is_ready_for_localization and (not self.document.latest_localizable_revision or self.id > self.document.latest_localizable_revision.id)): # We are marking a newer revision as ready for l10n. # Update the denormalized field on the document. self.document.latest_localizable_revision = self self.document.save()