Merge remote-tracking branch 'origin/v3.6'

This commit is contained in:
Adolfo Gómez García 2022-09-12 12:40:16 +02:00
commit ce8bb30cf1
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
3 changed files with 24 additions and 15 deletions

View File

@ -1,4 +0,0 @@
Linux:
python3-prctl (recommended, but not required in fact)
python3-pyqt5

View File

@ -217,7 +217,7 @@
<string>UDS Service Token</string>
</property>
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Administrator user on UDS Server.&lt;/p&gt;&lt;p&gt;Note: This credential will not be stored on client. Will be used to obtain an unique token for this image.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Token of the service on UDS platform&lt;/p&gt;&lt;p&gt;This token can be obtainend from the service configuration on UDS.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
@ -268,10 +268,10 @@
<item row="3" column="1">
<widget class="QLineEdit" name="restrictNet">
<property name="toolTip">
<string>UDS user with administration rights (Will not be stored on template)</string>
<string>Restrict valid detection of network interfaces to this network.</string>
</property>
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Administrator user on UDS Server.&lt;/p&gt;&lt;p&gt;Note: This credential will not be stored on client. Will be used to obtain an unique token for this image.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Restrics valid detection of network interfaces.&lt;/p&gt;&lt;p&gt;Note: Use this field only in case of several network interfaces, so UDS knows which one is the interface where the user will be connected..&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>

View File

@ -37,6 +37,7 @@ import pickle
import copy
import typing
import logging
from collections import abc
from django.utils.translation import get_language, gettext as _, gettext_noop
from django.conf import settings
@ -122,20 +123,31 @@ class gui:
# Helpers
@staticmethod
def convertToChoices(
vals: typing.Union[typing.List[str], typing.MutableMapping[str, str]]
vals: typing.Union[typing.Iterable[typing.Union[str, typing.Dict[str, str]]], typing.Dict[str, str]]
) -> typing.List[typing.Dict[str, str]]:
"""
Helper to convert from array of strings to the same dict used in choice,
Helper to convert from array of strings (or dictionaries) to the same dict used in choice,
multichoice, ..
"""
if not vals:
return []
if isinstance(vals, (list, tuple)):
return [{'id': v, 'text': v} for v in vals]
# Helper to convert an item to a dict
def choiceFromValue(val: typing.Union[str, typing.Dict[str, str]]) -> typing.Dict[str, str]:
if isinstance(val, str):
return {'id': val, 'name': val}
# Return a deepcopy
return copy.deepcopy(val)
# Dictionary
# If is an iterator
if isinstance(vals, abc.Iterable):
return [choiceFromValue(v) for v in vals]
# If is a dict
if isinstance(vals, abc.Mapping):
return [{'id': str(k), 'text': v} for k, v in vals.items()]
raise ValueError('Invalid type for convertToChoices: {}'.format(type(vals)))
@staticmethod
def convertToList(vals: typing.Iterable[str]) -> typing.List[str]:
if vals:
@ -780,7 +792,8 @@ class gui:
def __init__(self, **options):
super().__init__(**options)
if options.get('values') and isinstance(options.get('values'), (dict, list, tuple)):
vals = options.get('values')
if vals and isinstance(vals, (dict, list, tuple)):
options['values'] = gui.convertToChoices(options['values'])
self._data['values'] = options.get('values', [])
if 'fills' in options:
@ -792,7 +805,7 @@ class gui:
gui.callbacks[fills['callbackName']] = fnc
self._type(gui.InputField.CHOICE_TYPE)
def setValues(self, values: typing.List[typing.Any]):
def setValues(self, values: typing.List[typing.Dict[str, typing.Any]]):
"""
Set the values for this choice field
"""