From 301d68b1a261a1ad0f0b06c1051627dad68908c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Fri, 29 Jul 2022 16:38:03 +0200 Subject: [PATCH] fixed authenticators rest --- server/src/uds/REST/methods/authenticators.py | 10 +++++----- server/src/uds/REST/processors.py | 10 ++++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/server/src/uds/REST/methods/authenticators.py b/server/src/uds/REST/methods/authenticators.py index 9a0241b0..f71461fc 100644 --- a/server/src/uds/REST/methods/authenticators.py +++ b/server/src/uds/REST/methods/authenticators.py @@ -96,10 +96,10 @@ class Authenticators(ModelHandler): def getGui(self, type_: str) -> typing.List[typing.Any]: try: - tgui = auths.factory().lookup(type_) - if tgui: + authType = auths.factory().lookup(type_) + if authType: field = self.addDefaultFields( - tgui.guiDescription(), + authType.guiDescription(), ['name', 'comments', 'tags', 'priority', 'small_name', 'networks'], ) self.addField( @@ -134,8 +134,8 @@ class Authenticators(ModelHandler): for v in MFA.objects.all() ] ), - 'label': ugettext('MFA Provider'), - 'tooltip': ugettext( + 'label': gettext('MFA Provider'), + 'tooltip': gettext( 'MFA provider to use for this authenticator' ), 'type': gui.InputField.CHOICE_TYPE, diff --git a/server/src/uds/REST/processors.py b/server/src/uds/REST/processors.py index fb1a4a8b..379f0fbe 100644 --- a/server/src/uds/REST/processors.py +++ b/server/src/uds/REST/processors.py @@ -38,12 +38,14 @@ import time import types import typing -from django import http +from django.http import HttpResponse # from xml_marshaller import xml_marshaller logger = logging.getLogger(__name__) +if typing.TYPE_CHECKING: + from django.http import HttpRequest class ParametersException(Exception): pass @@ -57,9 +59,9 @@ class ContentProcessor: mime_type: typing.ClassVar[str] = '' extensions: typing.ClassVar[typing.Iterable[str]] = [] - _request: http.HttpRequest + _request: 'HttpRequest' - def __init__(self, request: http.HttpRequest): + def __init__(self, request: 'HttpRequest'): self._request = request def processGetParameters(self) -> typing.MutableMapping[str, typing.Any]: @@ -83,7 +85,7 @@ class ContentProcessor: Converts an obj to a response of specific type (json, XML, ...) This is done using "render" method of specific type """ - return http.HttpResponse( + return HttpResponse( content=self.render(obj), content_type=self.mime_type + "; charset=utf-8" )