mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-11 05:17:55 +03:00
Fixed typos refactoring constants and types
This commit is contained in:
parent
4c21919846
commit
f67de32f92
@ -38,7 +38,8 @@ from django.utils.translation import gettext as _
|
||||
|
||||
from uds.models import Calendar, CalendarAction
|
||||
from uds.models.calendar_action import CALENDAR_ACTION_DICT
|
||||
from uds.core.types import log, permissions
|
||||
from uds.core import types
|
||||
from uds.core.util import log
|
||||
from uds.core.util.model import processUuid
|
||||
|
||||
from uds.REST.model import DetailHandler
|
||||
@ -238,7 +239,7 @@ class ActionsCalendars(DetailHandler):
|
||||
logger.debug('Launching action')
|
||||
uuid = processUuid(item)
|
||||
calendarAction: CalendarAction = CalendarAction.objects.get(uuid=uuid)
|
||||
self.ensureAccess(calendarAction, permissions.PermissionType.MANAGEMENT)
|
||||
self.ensureAccess(calendarAction, types.permissions.PermissionType.MANAGEMENT)
|
||||
|
||||
logStr = (
|
||||
f'Launched scheduled action "{calendarAction.calendar.name},'
|
||||
|
@ -36,7 +36,8 @@ from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from uds import models
|
||||
from uds.core import consts, exceptions, types
|
||||
from uds.core.types import blocker, permissions
|
||||
from uds.core.types import permissions
|
||||
from uds.core.util import blocker
|
||||
from uds.core.util.log import LogLevel
|
||||
from uds.core.util.model import getSqlDatetime, getSqlDatetimeAsUnix
|
||||
from uds.core.util.os_detector import KnownOS
|
||||
|
@ -105,14 +105,14 @@ class TunnelServers(DetailHandler):
|
||||
]
|
||||
|
||||
def saveItem(self, parent: 'RegisteredServerGroup', item: typing.Optional[str]) -> None:
|
||||
# Item is always None here, because we can "add" existing servers to a group, but not create new ones
|
||||
# Item is the uuid of the server to add
|
||||
server: typing.Optional['RegisteredServer'] = None # Avoid warning on reference before assignment
|
||||
|
||||
if item is not None:
|
||||
raise self.invalidRequestException('Cannot create new servers from here')
|
||||
if item is None:
|
||||
raise self.invalidItemException('No server specified')
|
||||
|
||||
try:
|
||||
server = RegisteredServer.objects.get(uuid=processUuid(self._params['id']))
|
||||
server = RegisteredServer.objects.get(uuid=processUuid(item))
|
||||
parent.servers.add(server)
|
||||
except Exception:
|
||||
raise self.invalidItemException() from None
|
||||
@ -159,18 +159,28 @@ class Tunnels(ModelHandler):
|
||||
]
|
||||
|
||||
def getGui(self, type_: str) -> typing.List[typing.Any]:
|
||||
return self.addField(
|
||||
self.addDefaultFields([], ['name', 'comments', 'tags']),
|
||||
return self.addDefaultFields(
|
||||
[
|
||||
{
|
||||
'name': 'net_string',
|
||||
'name': 'host',
|
||||
'value': '',
|
||||
'label': gettext('Network range'),
|
||||
'label': gettext('Hostname'),
|
||||
'tooltip': gettext(
|
||||
'Network range. Accepts most network definitions formats (range, subnet, host, etc...'
|
||||
'Hostname or IP address of the server where the tunnel is visible by the users'
|
||||
),
|
||||
'type': gui.InputField.Types.TEXT,
|
||||
'order': 100, # At end
|
||||
},
|
||||
{
|
||||
'name': 'port',
|
||||
'value': 443,
|
||||
'label': gettext('Port'),
|
||||
'tooltip': gettext('Port where the tunnel is visible by the users'),
|
||||
'type': gui.InputField.Types.NUMERIC,
|
||||
'order': 101, # At end
|
||||
},
|
||||
],
|
||||
['name', 'comments', 'tags'],
|
||||
)
|
||||
|
||||
def item_as_dict(self, item: 'RegisteredServerGroup') -> typing.Dict[str, typing.Any]:
|
||||
@ -184,3 +194,7 @@ class Tunnels(ModelHandler):
|
||||
'servers_count': item.servers.count(),
|
||||
'permission': permissions.getEffectivePermission(self._user, item),
|
||||
}
|
||||
|
||||
def beforeSave(self, fields: typing.Dict[str, typing.Any]) -> None:
|
||||
fields['kind'] = types.servers.ServerType.TUNNEL.value
|
||||
fields['port'] = int(fields['port'])
|
||||
|
@ -32,27 +32,25 @@
|
||||
# pylint: disable=too-many-public-methods
|
||||
|
||||
import fnmatch
|
||||
import logging
|
||||
import re
|
||||
import types
|
||||
import typing
|
||||
|
||||
import logging
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
from django.db import IntegrityError, models
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from uds.core.consts import OK
|
||||
import uds.core.types.permissions
|
||||
|
||||
from uds.core.ui import gui as uiGui
|
||||
from uds.core.util import log
|
||||
from uds.core.util import permissions
|
||||
from uds.core.util.model import processUuid
|
||||
from uds.core.module import Module
|
||||
from uds.core import exceptions as g_exceptions
|
||||
|
||||
from uds.models import Tag, TaggingMixin, ManagedObjectModel, Network
|
||||
from uds.core.module import Module
|
||||
from uds.core.ui import gui as uiGui
|
||||
from uds.core.util import log, permissions
|
||||
from uds.core.util.model import processUuid
|
||||
from uds.models import ManagedObjectModel, Network, Tag, TaggingMixin
|
||||
from uds.REST.utils import rest_result
|
||||
|
||||
from . import exceptions
|
||||
|
||||
from .handlers import Handler
|
||||
|
||||
# Not imported at runtime, just for type checking
|
||||
@ -68,10 +66,6 @@ TABLEINFO: typing.Final[str] = 'tableinfo'
|
||||
GUI: typing.Final[str] = 'gui'
|
||||
LOG: typing.Final[str] = 'log'
|
||||
|
||||
OK: typing.Final[
|
||||
str
|
||||
] = 'ok' # Constant to be returned when result is just "operation complete successfully"
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
class BaseModelHandler(Handler):
|
||||
"""
|
||||
@ -554,7 +548,7 @@ class DetailHandler(BaseModelHandler):
|
||||
logger.debug('Invoking proper saving detail item %s', item)
|
||||
self.saveItem(parent, item)
|
||||
# Empty response
|
||||
return ''
|
||||
return rest_result(OK)
|
||||
|
||||
def post(self) -> typing.Any:
|
||||
"""
|
||||
|
@ -48,3 +48,7 @@ MAC_UNKNOWN: typing.Final[str] = '00:00:00:00:00:00'
|
||||
# Default UDS Registerd Server listen port
|
||||
SERVER_DEFAULT_LISTEN_PORT: typing.Final[int] = 43910
|
||||
|
||||
# REST Related constants
|
||||
OK: typing.Final[
|
||||
str
|
||||
] = 'ok' # Constant to be returned when result is just "operation complete successfully"
|
||||
|
@ -29,8 +29,6 @@
|
||||
"""
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import datetime
|
||||
import codecs
|
||||
import typing
|
||||
import functools
|
||||
import logging
|
||||
|
Loading…
Reference in New Issue
Block a user