From: Michael Tremer Date: Wed, 22 Jan 2025 14:03:58 +0000 (+0000) Subject: web: Remove any old UI methods X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9a7829aba1b6a1f534f07e9d4b7704d0ad241d6;p=pbs.git web: Remove any old UI methods Signed-off-by: Michael Tremer --- diff --git a/src/web/__init__.py b/src/web/__init__.py index 8eeae350..e53e21f5 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -1,15 +1,12 @@ #!/usr/bin/python # encoding: utf-8 -import datetime import logging import tornado.locale import tornado.web -import urllib.parse from .. import Backend from ..constants import * -from .. import misc # Import all handlers from . import auth @@ -35,10 +32,6 @@ class Application(tornado.web.Application): login_url = "/login", template_path = TEMPLATESDIR, static_path = STATICDIR, - ui_methods = { - "group" : self.group, - "make_url" : self.make_url, - }, xsrf_cookies = True, xsrf_cookie_kwargs = { "secure" : True, @@ -206,21 +199,3 @@ class Application(tornado.web.Application): self.backend.launch_background_tasks() logging.info("Successfully initialied application") - - ## UI methods - - def group(self, handler, *args, **kwargs): - return misc.group(*args, **kwargs) - - def make_url(self, url, **kwargs): - # Format any query arguments and append them to the URL - if kwargs: - # Filter out None - args = { k : kwargs[k] for k in kwargs if kwargs[k] is not None } - - # Encode into URL format - args = urllib.parse.urlencode(args) - - url = "%s?%s" % (url, args) - - return url diff --git a/src/web/base.py b/src/web/base.py index e1d4b3c0..4f0857ef 100644 --- a/src/web/base.py +++ b/src/web/base.py @@ -26,7 +26,6 @@ import urllib.parse from .. import __version__ from .. import builders -from .. import misc from .. import users from ..decorators import * @@ -277,7 +276,7 @@ class BaseHandler(tornado.web.RequestHandler): "datetime" : datetime, # Functions - "make_url" : self.application.make_url, + "make_url" : self.make_url, } # Custom Filters @@ -327,6 +326,21 @@ class BaseHandler(tornado.web.RequestHandler): return ns + def make_url(self, url, **kwargs): + """ + Formats any query arguments and append them to the URL + """ + if kwargs: + # Filter out None + args = { k : kwargs[k] for k in kwargs if kwargs[k] is not None } + + # Encode into URL format + args = urllib.parse.urlencode(args) + + url = "%s?%s" % (url, args) + + return url + async def render_string(self, template_name, **kwargs): """ Generates the given template with the given arguments.