diff options
Diffstat (limited to 'backend/Admin.py')
-rw-r--r-- | backend/Admin.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/backend/Admin.py b/backend/Admin.py index a844aff..2070293 100644 --- a/backend/Admin.py +++ b/backend/Admin.py @@ -8,7 +8,10 @@ template_factory = jinja2.Environment(loader=jinja2.FileSystemLoader('../interfa admin_dirs = template_factory.get_template("admin_dirs.tmpl") admin_files = template_factory.get_template("admin_files.tmpl") +admin_upload = template_factory.get_template("admin_upload.tmpl") admin_delete = template_factory.get_template("admin_delete.tmpl") +admin_rename = template_factory.get_template("admin_rename.tmpl") +admin_aliases = template_factory.get_template("admin_aliases.tmpl") def route(path, env, post): auth = config.Auth.get(env) @@ -39,11 +42,19 @@ def route(path, env, post): files = utils.dirlisting(directory, True, False) return [admin_files.render({"user": auth["user"], "listing": files, "directory": utils.sanitize_filename(path[1])}), [("Content-Type", "text/html")], "200 OK"] + # Upload + if len(path) == 3 and path[2] == "upload": + return [admin_upload.render({"user": auth["user"], "directory": utils.sanitize_filename(path[1])}), [("Content-Type", "text/html")], "200 OK"] + # Alias management / Limits config - # TODO + if len(path) == 3 and path[2] == "aliases": + aliases = utils.aliases(auth["user"], utils.sanitize_filename(path[1])) + return [admin_aliases.render({"user": auth["user"], "directory": utils.sanitize_filename(path[1]), "aliases": aliases, "baseurl": config.baseurl}), [("Content-Type", "text/html")], "200 OK"] # Renaming - # TODO + if len(path) == 3 and path[2] == "rename": + # TODO + return [admin_rename.render({"user": auth["user"], "directory": utils.sanitize_filename(path[1])}), [("Content-Type", "text/html")], "200 OK"] # Deletion if len(path) == 3 and path[2] == "delete": @@ -52,9 +63,7 @@ def route(path, env, post): return utils.redirect("/admin") files = utils.dirlisting(directory, True, False) if len(files) == 0 or env.get("QUERY_STRING", "") == "confirm": - # TODO remove contents - # TODO remove aliases - os.rmdir(directory) + utils.cleanup(auth["user"], utils.sanitize_filename(path[1])) return utils.redirect("/admin") return [admin_delete.render({"user": auth["user"], "listing": files, "directory": utils.sanitize_filename(path[1])}), [("Content-Type", "text/html")], "200 OK"] |