mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-10 01:17:59 +03:00
Merge remote-tracking branch 'origin/v3.6'
This commit is contained in:
commit
ec9811dc34
@ -43,7 +43,7 @@ logger = logging.getLogger(__name__)
|
||||
class Config(Handler):
|
||||
needs_admin = True # By default, staff is lower level needed
|
||||
|
||||
def get(self):
|
||||
def get(self) -> typing.Any:
|
||||
cfg: CfgConfig.Value
|
||||
|
||||
return CfgConfig.getConfigValues(self.is_admin())
|
||||
|
@ -173,7 +173,7 @@ class MetaPools(ModelHandler):
|
||||
'values': [gui.choiceImage(-1, '--------', DEFAULT_THUMB_BASE64)]
|
||||
+ gui.sortedChoices(
|
||||
[
|
||||
gui.choiceImage(v.uuid, v.name, v.thumb64)
|
||||
gui.choiceImage(v.uuid, v.name, v.thumb64) # type: ignore
|
||||
for v in Image.objects.all()
|
||||
]
|
||||
),
|
||||
@ -188,7 +188,7 @@ class MetaPools(ModelHandler):
|
||||
'values': [gui.choiceImage(-1, _('Default'), DEFAULT_THUMB_BASE64)]
|
||||
+ gui.sortedChoices(
|
||||
[
|
||||
gui.choiceImage(v.uuid, v.name, v.thumb64)
|
||||
gui.choiceImage(v.uuid, v.name, v.thumb64) # type: ignore
|
||||
for v in ServicePoolGroup.objects.all()
|
||||
]
|
||||
),
|
||||
|
@ -97,10 +97,10 @@ class Permissions(Handler):
|
||||
{
|
||||
'id': perm.uuid,
|
||||
'type': kind,
|
||||
'auth': entity.manager.uuid,
|
||||
'auth_name': entity.manager.name,
|
||||
'entity_id': entity.uuid,
|
||||
'entity_name': entity.name,
|
||||
'auth': entity.manager.uuid, # type: ignore
|
||||
'auth_name': entity.manager.name, # type: ignore
|
||||
'entity_id': entity.uuid, # type: ignore
|
||||
'entity_name': entity.name, # type: ignore
|
||||
'perm': perm.permission,
|
||||
'perm_name': perm.permission_as_string,
|
||||
}
|
||||
@ -108,7 +108,7 @@ class Permissions(Handler):
|
||||
|
||||
return sorted(res, key=lambda v: v['auth_name'] + v['entity_name'])
|
||||
|
||||
def get(self):
|
||||
def get(self) -> typing.Any:
|
||||
"""
|
||||
Processes get requests
|
||||
"""
|
||||
|
@ -93,7 +93,7 @@ class ServicesPoolGroups(ModelHandler):
|
||||
'values': [gui.choiceImage(-1, '--------', DEFAULT_THUMB_BASE64)]
|
||||
+ gui.sortedChoices(
|
||||
[
|
||||
gui.choiceImage(v.uuid, v.name, v.thumb64)
|
||||
gui.choiceImage(v.uuid, v.name, v.thumb64) # type: ignore
|
||||
for v in Image.objects.all()
|
||||
]
|
||||
),
|
||||
|
@ -233,8 +233,8 @@ class ServicesPools(ModelHandler):
|
||||
'name': item.name,
|
||||
'short_name': item.short_name,
|
||||
'tags': [tag.tag for tag in item.tags.all()],
|
||||
'parent': item.service.name,
|
||||
'parent_type': item.service.data_type,
|
||||
'parent': item.service.name, # type: ignore
|
||||
'parent_type': item.service.data_type, # type: ignore
|
||||
'comments': item.comments,
|
||||
'state': state,
|
||||
'thumb': item.image.thumb64
|
||||
@ -242,8 +242,8 @@ class ServicesPools(ModelHandler):
|
||||
else DEFAULT_THUMB_BASE64,
|
||||
'account': item.account.name if item.account is not None else '',
|
||||
'account_id': item.account.uuid if item.account is not None else None,
|
||||
'service_id': item.service.uuid,
|
||||
'provider_id': item.service.provider.uuid,
|
||||
'service_id': item.service.uuid, # type: ignore
|
||||
'provider_id': item.service.provider.uuid, # type: ignore
|
||||
'image_id': item.image.uuid if item.image is not None else None,
|
||||
'initial_srvs': item.initial_srvs,
|
||||
'cache_l1_srvs': item.cache_l1_srvs,
|
||||
@ -297,7 +297,7 @@ class ServicesPools(ModelHandler):
|
||||
val['tags'] = [tag.tag for tag in item.tags.all()]
|
||||
val['restrained'] = restrained
|
||||
val['permission'] = permissions.getEffectivePermission(self._user, item)
|
||||
val['info'] = Services.serviceInfo(item.service)
|
||||
val['info'] = Services.serviceInfo(item.service) # type: ignore
|
||||
val['pool_group_id'] = poolGroupId
|
||||
val['pool_group_name'] = poolGroupName
|
||||
val['pool_group_thumb'] = poolGroupThumb
|
||||
@ -325,7 +325,7 @@ class ServicesPools(ModelHandler):
|
||||
'values': [gui.choiceItem('', '')]
|
||||
+ gui.sortedChoices(
|
||||
[
|
||||
gui.choiceItem(v.uuid, v.provider.name + '\\' + v.name)
|
||||
gui.choiceItem(v.uuid, v.provider.name + '\\' + v.name) # type: ignore
|
||||
for v in Service.objects.all()
|
||||
]
|
||||
),
|
||||
@ -339,7 +339,7 @@ class ServicesPools(ModelHandler):
|
||||
'name': 'osmanager_id',
|
||||
'values': [gui.choiceItem(-1, '')]
|
||||
+ gui.sortedChoices(
|
||||
[gui.choiceItem(v.uuid, v.name) for v in OSManager.objects.all()]
|
||||
[gui.choiceItem(v.uuid, v.name) for v in OSManager.objects.all()] # type: ignore
|
||||
),
|
||||
'label': gettext('OS Manager'),
|
||||
'tooltip': gettext('OS Manager used as base of this service pool'),
|
||||
@ -394,7 +394,7 @@ class ServicesPools(ModelHandler):
|
||||
'values': [gui.choiceImage(-1, '--------', DEFAULT_THUMB_BASE64)]
|
||||
+ gui.sortedChoices(
|
||||
[
|
||||
gui.choiceImage(v.uuid, v.name, v.thumb64)
|
||||
gui.choiceImage(v.uuid, v.name, v.thumb64) # type: ignore
|
||||
for v in Image.objects.all()
|
||||
]
|
||||
),
|
||||
@ -409,7 +409,7 @@ class ServicesPools(ModelHandler):
|
||||
'values': [gui.choiceImage(-1, _('Default'), DEFAULT_THUMB_BASE64)]
|
||||
+ gui.sortedChoices(
|
||||
[
|
||||
gui.choiceImage(v.uuid, v.name, v.thumb64)
|
||||
gui.choiceImage(v.uuid, v.name, v.thumb64) # type: ignore
|
||||
for v in ServicePoolGroup.objects.all()
|
||||
]
|
||||
),
|
||||
@ -493,7 +493,7 @@ class ServicesPools(ModelHandler):
|
||||
'name': 'account_id',
|
||||
'values': [gui.choiceItem(-1, '')]
|
||||
+ gui.sortedChoices(
|
||||
[gui.choiceItem(v.uuid, v.name) for v in Account.objects.all()]
|
||||
[gui.choiceItem(v.uuid, v.name) for v in Account.objects.all()] # type: ignore
|
||||
),
|
||||
'label': gettext('Accounting'),
|
||||
'tooltip': gettext('Account associated to this service pool'),
|
||||
@ -659,7 +659,7 @@ class ServicesPools(ModelHandler):
|
||||
# Returns the action list based on current element, for calendar
|
||||
def actionsList(self, item: ServicePool) -> typing.Any:
|
||||
validActions: typing.Tuple[typing.Dict, ...] = ()
|
||||
itemInfo = item.service.getType()
|
||||
itemInfo = item.service.getType() # type: ignore
|
||||
if itemInfo.usesCache is True:
|
||||
validActions += (
|
||||
CALENDAR_ACTION_INITIAL,
|
||||
@ -691,7 +691,7 @@ class ServicesPools(ModelHandler):
|
||||
return validActions
|
||||
|
||||
def listAssignables(self, item: ServicePool) -> typing.Any:
|
||||
service = item.service.getInstance()
|
||||
service = item.service.getInstance() # type: ignore
|
||||
return [gui.choiceItem(i[0], i[1]) for i in service.listAssignables()]
|
||||
|
||||
def createFromAssignable(self, item: ServicePool) -> typing.Any:
|
||||
|
@ -77,8 +77,8 @@ class ServicesUsage(DetailHandler):
|
||||
'friendly_name': item.friendly_name,
|
||||
'owner': owner,
|
||||
'owner_info': owner_info,
|
||||
'service': item.deployed_service.service.name,
|
||||
'service_id': item.deployed_service.service.uuid,
|
||||
'service': item.deployed_service.service.name, # type: ignore
|
||||
'service_id': item.deployed_service.service.uuid, # type: ignore
|
||||
'pool': item.deployed_service.name,
|
||||
'pool_id': item.deployed_service.uuid,
|
||||
'ip': props.get('ip', _('unknown')),
|
||||
|
@ -171,7 +171,7 @@ class Tickets(Handler):
|
||||
groupIds: typing.List[str] = []
|
||||
for groupName in tools.as_list(self.getParam('groups')):
|
||||
try:
|
||||
groupIds.append(auth.groups.get(name=groupName).uuid)
|
||||
groupIds.append(auth.groups.get(name=groupName).uuid or '')
|
||||
except Exception:
|
||||
logger.info(
|
||||
'Group %s from ticket does not exists on auth %s, forced creation: %s',
|
||||
@ -184,7 +184,7 @@ class Tickets(Handler):
|
||||
auth.groups.create(
|
||||
name=groupName,
|
||||
comments='Autocreated form ticket by using force paratemeter',
|
||||
).uuid
|
||||
).uuid or ''
|
||||
)
|
||||
|
||||
if not groupIds: # No valid group in groups names
|
||||
@ -244,7 +244,7 @@ class Tickets(Handler):
|
||||
):
|
||||
pool.assignedGroups.add(auth.groups.get(uuid=addGrp))
|
||||
|
||||
servicePoolId = 'F' + pool.uuid
|
||||
servicePoolId = 'F' + pool.uuid # type: ignore
|
||||
|
||||
except models.Authenticator.DoesNotExist:
|
||||
return Tickets.result(error='Authenticator does not exists')
|
||||
|
@ -94,7 +94,7 @@ def getUDSCookie(
|
||||
if 'uds' not in request.COOKIES:
|
||||
cookie = cryptoManager().randomString(UDS_COOKIE_LENGTH)
|
||||
if response is not None:
|
||||
response.set_cookie('uds', cookie, samesite='Lax')
|
||||
response.set_cookie('uds', cookie, samesite='Lax', httponly=GlobalConfig.ENHANCED_SECURITY.getBool())
|
||||
request.COOKIES['uds'] = cookie
|
||||
else:
|
||||
cookie = request.COOKIES['uds'][:UDS_COOKIE_LENGTH]
|
||||
|
@ -175,7 +175,7 @@ class Authenticator(ManagedObjectModel, TaggingMixin):
|
||||
if (
|
||||
user.real_name.strip() == '' or user.name.strip() == user.real_name.strip()
|
||||
) and realName != user.real_name:
|
||||
user.real_name = realName
|
||||
user.real_name = realName or ''
|
||||
user.save(update_fields=['real_name'])
|
||||
|
||||
return user
|
||||
|
@ -65,6 +65,7 @@ class Calendar(UUIDModel, TaggingMixin):
|
||||
db_table = 'uds_calendar'
|
||||
app_label = 'uds'
|
||||
|
||||
# Override default save to add uuid
|
||||
def save(
|
||||
self,
|
||||
*args,
|
||||
|
@ -282,7 +282,7 @@ class ServicePool(UUIDModel, TaggingMixin): # type: ignore
|
||||
return self.service.isInMaintenance() if self.service else True
|
||||
|
||||
def isVisible(self) -> bool:
|
||||
return self.visible
|
||||
return self.visible # type: ignore
|
||||
|
||||
def isUsable(self) -> bool:
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user