{{ _("Do you really want to restore this page to its revision from %s?") % locale.format_date(page.timestamp) }}
</p>
- <form action="/actions/restore" method="POST">
+ <form action="/docs/_restore" method="POST">
{% raw xsrf_form_html() %}
<input type="hidden" name="path" value="{{ page.page }}">
(r"/docs/search", docs.SearchHandler),
(r"/docs/tree", docs.TreeHandler),
(r"/docs/watchlist", docs.WatchlistHandler),
+ (r"/docs/_restore", docs.RestoreHandler),
(r"/docs/_upload", docs.UploadHandler),
(r"/docs/([A-Za-z0-9\-_\/]+)?/_edit", docs.EditHandler),
(r"/docs/([A-Za-z0-9\-_\/]+)?/_render", docs.RenderHandler),
authentication_handlers + [
# Actions
- (r"/actions/restore", wiki.ActionRestoreHandler),
+
# Serve any static files
(r"/static/(.*)", tornado.web.StaticFileHandler, { "path" : self.settings.get("static_path") }),
self.finish(html)
+class RestoreHandler(base.BaseHandler):
+ @tornado.web.authenticated
+ @base.ratelimit(minutes=60, requests=24)
+ def post(self):
+ path = self.get_argument("path")
+
+ # Check permissions
+ if not self.backend.wiki.check_acl(path, self.current_user):
+ raise tornado.web.HTTPError(403, "Access to %s not allowed for %s" % (path, self.current_user))
+
+ # 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(),
+ comment=comment,
+ )
+
+ # Redirect back to page
+ self.redirect(page.page)
+
+
class UploadHandler(base.BaseHandler):
@tornado.web.authenticated
@base.ratelimit(minutes=60, requests=24)
#!/usr/bin/python3
-import tornado.web
-
-from . import base
from . import ui_modules
-class ActionRestoreHandler(base.BaseHandler):
- @tornado.web.authenticated
- @base.ratelimit(minutes=60, requests=24)
- def post(self):
- path = self.get_argument("path")
-
- # Check permissions
- if not self.backend.wiki.check_acl(path, self.current_user):
- raise tornado.web.HTTPError(403, "Access to %s not allowed for %s" % (path, self.current_user))
-
- # 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(),
- comment=comment,
- )
-
- # Redirect back to page
- self.redirect(page.page)
-
-
class WikiListModule(ui_modules.UIModule):
def render(self, pages, link_revision=False, show_breadcrumbs=True,
show_author=True, show_changes=False):