fixed authenticators rest

This commit is contained in:
Adolfo Gómez García 2022-07-29 16:38:03 +02:00
parent 46b6bb2305
commit 301d68b1a2
2 changed files with 11 additions and 9 deletions

View File

@ -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,

View File

@ -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"
)