]> git.ipfire.org Git - ipfire.org.git/commitdiff
wiki: Allow adding a comment when a page is being restored
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 19 May 2020 16:30:51 +0000 (16:30 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 19 May 2020 16:30:51 +0000 (16:30 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/wiki.py
src/templates/wiki/confirm-restore.html
src/web/wiki.py

index d2212ec930869bcbb0ab07172d6537f346fda9ee..8237da97ef6e5a18a9c8b20715bcf71a9da39e58 100644 (file)
@@ -453,9 +453,13 @@ class Page(misc.Object):
                        self.backend.messages.send_template("wiki/messages/page-changed",
                                account=watcher, page=self, priority=-10)
 
-       def restore(self, author, address):
+       def restore(self, author, address, comment=None):
                changes = "Restore to revision from %s" % self.timestamp.isoformat()
 
+               # Append comment
+               if comment:
+                       changes = "%s: %s" % (changes, comment)
+
                return self.backend.wiki.create_page(self.page,
                        author, self.markdown, changes=changes, address=address)
 
index f9acfaed9c747ef712899cdc48667344db6d7c8e..7bebd42c155273e0291d7c3ce7fd1f64dd37bc32 100644 (file)
                                        <input type="hidden" name="path" value="{{ page.page }}">
                                        <input type="hidden" name="revision" value="{{ page.timestamp.isoformat() }}">
 
+                                       <div class="form-group">
+                                               <input class="form-control" type="text" name="comment"
+                                                       placeholder="{{ _("Comment") }}">
+                                       </div>
+
                                        <button type="submit" class="btn btn-warning btn-block">
                                                {{ _("Restore") }}
                                        </button>
index f417e22ab060fcaa7ad0e15e7cedb8a7679c2302..edc52730ce62e1d92c1ff983b10d99099796c3c9 100644 (file)
@@ -138,13 +138,16 @@ class ActionRestoreHandler(auth.CacheMixin, base.BaseHandler):
 
                # Check if we are asked to render a certain revision
                revision = self.get_argument("revision", None)
+               comment = self.get_argument("comment", None)
 
                # Fetch the wiki page
                page = self.backend.wiki.get_page(path, revision=revision)
 
                with self.db.transaction():
                        page = page.restore(
-                               author=self.current_user, address=self.get_remote_ip(),
+                               author=self.current_user,
+                               address=self.get_remote_ip(),
+                               comment=comment,
                        )
 
                # Redirect back to page