code: def revert(self):
          
  
          with self.draft_context():
              draft = self.one(Q._uid == self._uid)
  
          with self.published_context():
              published = self.one(Q._uid == self._uid)
  
          for field, value in draft._document.items():
              if field in self._unpublished_fields:
                  continue
              setattr(draft, field, getattr(published, field))
  
          # Revert the revision
          draft.revision = published.revision
  
          draft.update()
docs: Revert the document to currently published version