forked from shaba/openuds
Merge remote-tracking branch 'origin/v3.6'
This commit is contained in:
commit
ce8bb30cf1
@ -1,4 +0,0 @@
|
|||||||
Linux:
|
|
||||||
python3-prctl (recommended, but not required in fact)
|
|
||||||
python3-pyqt5
|
|
||||||
|
|
@ -217,7 +217,7 @@
|
|||||||
<string>UDS Service Token</string>
|
<string>UDS Service Token</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="whatsThis">
|
<property name="whatsThis">
|
||||||
<string><html><head/><body><p>Administrator user on UDS Server.</p><p>Note: This credential will not be stored on client. Will be used to obtain an unique token for this image.</p></body></html></string>
|
<string><html><head/><body><p>Token of the service on UDS platform</p><p>This token can be obtainend from the service configuration on UDS.</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -268,10 +268,10 @@
|
|||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QLineEdit" name="restrictNet">
|
<widget class="QLineEdit" name="restrictNet">
|
||||||
<property name="toolTip">
|
<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>
|
||||||
<property name="whatsThis">
|
<property name="whatsThis">
|
||||||
<string><html><head/><body><p>Administrator user on UDS Server.</p><p>Note: This credential will not be stored on client. Will be used to obtain an unique token for this image.</p></body></html></string>
|
<string><html><head/><body><p>Restrics valid detection of network interfaces.</p><p>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..</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -37,6 +37,7 @@ import pickle
|
|||||||
import copy
|
import copy
|
||||||
import typing
|
import typing
|
||||||
import logging
|
import logging
|
||||||
|
from collections import abc
|
||||||
|
|
||||||
from django.utils.translation import get_language, gettext as _, gettext_noop
|
from django.utils.translation import get_language, gettext as _, gettext_noop
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@ -122,20 +123,31 @@ class gui:
|
|||||||
# Helpers
|
# Helpers
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def convertToChoices(
|
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]]:
|
) -> 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, ..
|
multichoice, ..
|
||||||
"""
|
"""
|
||||||
if not vals:
|
if not vals:
|
||||||
return []
|
return []
|
||||||
if isinstance(vals, (list, tuple)):
|
# Helper to convert an item to a dict
|
||||||
return [{'id': v, 'text': v} for v in vals]
|
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()]
|
return [{'id': str(k), 'text': v} for k, v in vals.items()]
|
||||||
|
|
||||||
|
raise ValueError('Invalid type for convertToChoices: {}'.format(type(vals)))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def convertToList(vals: typing.Iterable[str]) -> typing.List[str]:
|
def convertToList(vals: typing.Iterable[str]) -> typing.List[str]:
|
||||||
if vals:
|
if vals:
|
||||||
@ -780,7 +792,8 @@ class gui:
|
|||||||
|
|
||||||
def __init__(self, **options):
|
def __init__(self, **options):
|
||||||
super().__init__(**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'])
|
options['values'] = gui.convertToChoices(options['values'])
|
||||||
self._data['values'] = options.get('values', [])
|
self._data['values'] = options.get('values', [])
|
||||||
if 'fills' in options:
|
if 'fills' in options:
|
||||||
@ -792,7 +805,7 @@ class gui:
|
|||||||
gui.callbacks[fills['callbackName']] = fnc
|
gui.callbacks[fills['callbackName']] = fnc
|
||||||
self._type(gui.InputField.CHOICE_TYPE)
|
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
|
Set the values for this choice field
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user