]> git.ipfire.org Git - ipfire.org.git/commitdiff
docs: Move delete file handler
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 1 Jul 2023 10:47:39 +0000 (10:47 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 1 Jul 2023 10:47:39 +0000 (10:47 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/templates/docs/confirm-delete.html [moved from src/templates/wiki/confirm-delete.html with 100% similarity]
src/web/__init__.py
src/web/docs.py
src/web/wiki.py

index 7962435d3001d227538ce15012c870d0a028effd..5c45458eee7b1118c49efec8b7f0974b34c90f8e 100644 (file)
@@ -200,6 +200,7 @@ templates_donate_messagesdir = $(templates_donatedir)/messages
 templates_docs_DATA = \
        src/templates/docs/404.html \
        src/templates/docs/base.html \
+       src/templates/docs/confirm-delete.html \
        src/templates/docs/confirm-restore.html \
        src/templates/docs/diff.html \
        src/templates/docs/edit.html \
@@ -347,9 +348,6 @@ templates_voip_modules_DATA = \
 
 templates_voip_modulesdir = $(templates_voipdir)/modules
 
-templates_wiki_DATA = \
-       src/templates/wiki/confirm-delete.html
-
 templates_wikidir = $(templatesdir)/wiki
 
 templates_wiki_files_DATA = \
index 3da28e232b679f8cf2a6201dae7f2a21b5ee4fd3..d573e0208c4518c3ea076cb1be5a1d1feff69567 100644 (file)
@@ -149,6 +149,7 @@ class Application(tornado.web.Application):
                        (r"/docs/([A-Za-z0-9\-_\/]+)?/_edit", docs.ActionEditHandler),
                        (r"/docs/([A-Za-z0-9\-_\/]+)?/_render", docs.ActionRenderHandler),
                        (r"/docs/([A-Za-z0-9\-_\/]+)?/_(watch|unwatch)", docs.ActionWatchHandler),
+                       (r"/docs/((?:[A-Za-z0-9\-_\/]+)?(?:.*)\.(?:\w+))/_delete", docs.DeleteFileHandler),
                        (r"/docs((?:[A-Za-z0-9\-_\/]+)?(?:.*)\.(?:\w+))$", docs.FileHandler),
                        (r"/docs([A-Za-z0-9\-_\/]+)?", docs.PageHandler),
 
@@ -349,7 +350,6 @@ class Application(tornado.web.Application):
                        authentication_handlers + [
 
                        # Actions
-                       (r"((?:[A-Za-z0-9\-_\/]+)?(?:.*)\.(?:\w+))/_delete", wiki.ActionDeleteHandler),
                        (r"/actions/restore", wiki.ActionRestoreHandler),
                        (r"/actions/upload", wiki.ActionUploadHandler),
 
index 6682bcd090c68c3432dd8fa28a405ec4d49f9ccd..84fa848cd2ea1c8301b661250d77de7b285de7f5 100644 (file)
@@ -239,6 +239,38 @@ class ActionWatchHandler(base.BaseHandler):
                self.redirect(page.url)
 
 
+class DeleteFileHandler(base.BaseHandler):
+       @tornado.web.authenticated
+       def get(self, 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))
+
+               # Fetch the file
+               file = self.backend.wiki.get_file_by_path(path)
+               if not file:
+                       raise tornado.web.HTTPError(404, "Could not find %s" % path)
+
+               self.render("docs/confirm-delete.html", file=file)
+
+       @tornado.web.authenticated
+       @base.ratelimit(minutes=60, requests=24)
+       def post(self, 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))
+
+               # Fetch the file
+               file = self.backend.wiki.get_file_by_path(path)
+               if not file:
+                       raise tornado.web.HTTPError(404, "Could not find %s" % path)
+
+               with self.db.transaction():
+                       file.delete(self.current_user)
+
+               self.redirect("%s/_files" % file.path)
+
+
 class SearchHandler(base.BaseHandler):
        @base.ratelimit(minutes=5, requests=25)
        def get(self):
index 4c4ba134536d85a7697d68c382f9ec6bd3688f6c..ba914ba12a23764f9e5caffc6f922b0702f23aed 100644 (file)
@@ -34,38 +34,6 @@ class ActionUploadHandler(base.BaseHandler):
                self.redirect("%s/_files" % path)
 
 
-class ActionDeleteHandler(base.BaseHandler):
-       @tornado.web.authenticated
-       def get(self, 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))
-
-               # Fetch the file
-               file = self.backend.wiki.get_file_by_path(path)
-               if not file:
-                       raise tornado.web.HTTPError(404, "Could not find %s" % path)
-
-               self.render("wiki/confirm-delete.html", file=file)
-
-       @tornado.web.authenticated
-       @base.ratelimit(minutes=60, requests=24)
-       def post(self, 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))
-
-               # Fetch the file
-               file = self.backend.wiki.get_file_by_path(path)
-               if not file:
-                       raise tornado.web.HTTPError(404, "Could not find %s" % path)
-
-               with self.db.transaction():
-                       file.delete(self.current_user)
-
-               self.redirect("%s/_files" % file.path)
-
-
 class ActionRestoreHandler(base.BaseHandler):
        @tornado.web.authenticated
        @base.ratelimit(minutes=60, requests=24)