mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-31 05:06:41 +00:00
fix
This commit is contained in:
parent
17831668af
commit
296412a6fd
|
@ -134,34 +134,36 @@ class EnumConfigItem(ConfigItem):
|
||||||
options: list[str]
|
options: list[str]
|
||||||
|
|
||||||
|
|
||||||
def config_item_to_graphql(item: ServiceConfigItem) -> ConfigItem:
|
def config_item_to_graphql(item: dict) -> ConfigItem:
|
||||||
if isinstance(item, StringServiceConfigItem):
|
item_type = item.get("type")
|
||||||
|
if item_type == "string":
|
||||||
return StringConfigItem(
|
return StringConfigItem(
|
||||||
id=item.id,
|
id=item["id"],
|
||||||
description=item.description,
|
description=item["description"],
|
||||||
widget=item.widget,
|
widget=item["widget"],
|
||||||
type=item.type,
|
type=item_type,
|
||||||
value=item.default_value,
|
value=item["default_value"],
|
||||||
regex=item.regex.pattern if item.regex else None,
|
regex=item.get("regex")
|
||||||
)
|
)
|
||||||
if isinstance(item, BoolServiceConfigItem):
|
elif item_type == "bool":
|
||||||
return BoolConfigItem(
|
return BoolConfigItem(
|
||||||
id=item.id,
|
id=item["id"],
|
||||||
description=item.description,
|
description=item["description"],
|
||||||
widget=item.widget,
|
widget=item["widget"],
|
||||||
type=item.type,
|
type=item_type,
|
||||||
value=item.default_value,
|
value=item["default_value"],
|
||||||
)
|
)
|
||||||
if isinstance(item, EnumServiceConfigItem):
|
elif item_type == "enum":
|
||||||
return EnumConfigItem(
|
return EnumConfigItem(
|
||||||
id=item.id,
|
id=item["id"],
|
||||||
description=item.description,
|
description=item["description"],
|
||||||
widget=item.widget,
|
widget=item["widget"],
|
||||||
type=item.type,
|
type=item_type,
|
||||||
value=item.default_value,
|
value=item["default_value"],
|
||||||
options=item.options,
|
options=item["options"],
|
||||||
)
|
)
|
||||||
raise ValueError(f"Unknown config item type {item}")
|
else:
|
||||||
|
raise ValueError(f"Unknown config item type {item_type}")
|
||||||
|
|
||||||
|
|
||||||
@strawberry.type
|
@strawberry.type
|
||||||
|
|
Loading…
Reference in a new issue