mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-25 13:31:27 +00:00
fix default value
This commit is contained in:
parent
c8d00e6c87
commit
09ccea0927
|
@ -51,6 +51,17 @@ class StringServiceConfigItem(ServiceConfigItem):
|
||||||
raise ValueError(f"Value {value} does not match regex {self.regex}")
|
raise ValueError(f"Value {value} does not match regex {self.regex}")
|
||||||
service_options[self.id] = value
|
service_options[self.id] = value
|
||||||
|
|
||||||
|
def as_dict(self, service_options):
|
||||||
|
return {
|
||||||
|
"id": self.id,
|
||||||
|
"type": self.type,
|
||||||
|
"description": self.description,
|
||||||
|
"widget": self.widget,
|
||||||
|
"value": self.get_value(service_options),
|
||||||
|
"default_value": self.default_value,
|
||||||
|
"regex": self.regex.pattern if self.regex else None,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class BoolServiceConfigItem(ServiceConfigItem):
|
class BoolServiceConfigItem(ServiceConfigItem):
|
||||||
def __init__(
|
def __init__(
|
||||||
|
@ -72,6 +83,16 @@ class BoolServiceConfigItem(ServiceConfigItem):
|
||||||
def set_value(self, value, service_options):
|
def set_value(self, value, service_options):
|
||||||
service_options[self.id] = value
|
service_options[self.id] = value
|
||||||
|
|
||||||
|
def as_dict(self, service_options):
|
||||||
|
return {
|
||||||
|
"id": self.id,
|
||||||
|
"type": self.type,
|
||||||
|
"description": self.description,
|
||||||
|
"widget": self.widget,
|
||||||
|
"value": self.get_value(service_options),
|
||||||
|
"default_value": self.default_value,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class EnumServiceConfigItem(ServiceConfigItem):
|
class EnumServiceConfigItem(ServiceConfigItem):
|
||||||
def __init__(
|
def __init__(
|
||||||
|
@ -96,3 +117,14 @@ class EnumServiceConfigItem(ServiceConfigItem):
|
||||||
if value not in self.options:
|
if value not in self.options:
|
||||||
raise ValueError(f"Value {value} not in options {self.options}")
|
raise ValueError(f"Value {value} not in options {self.options}")
|
||||||
service_options[self.id] = value
|
service_options[self.id] = value
|
||||||
|
|
||||||
|
def as_dict(self, service_options):
|
||||||
|
return {
|
||||||
|
"id": self.id,
|
||||||
|
"type": self.type,
|
||||||
|
"description": self.description,
|
||||||
|
"widget": self.widget,
|
||||||
|
"value": self.get_value(service_options),
|
||||||
|
"default_value": self.default_value,
|
||||||
|
"options": self.options,
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue