Skip to content

Commit 549550b

Browse files
author
David Straub
authored
Fix for type conversion (#221)
1 parent fede86f commit 549550b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

gramps_webapi/api/resources/util.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
import gramps
3030
import jsonschema
31-
from flask import abort
31+
from flask import abort, current_app
3232
from gramps.gen.const import GRAMPS_LOCALE as glocale
3333
from gramps.gen.db import KEY_TO_CLASS_MAP, DbTxn
3434
from gramps.gen.db.base import DbReadBase, DbWriteBase
@@ -813,7 +813,8 @@ def validate_object_dict(obj_dict: Dict[str, Any]) -> bool:
813813
obj_dict_fixed = {k: v for k, v in obj_dict.items() if k != "complete"}
814814
try:
815815
jsonschema.validate(obj_dict_fixed, schema)
816-
except jsonschema.exceptions.ValidationError:
816+
except jsonschema.exceptions.ValidationError as exc:
817+
current_app.log_exception(exc)
817818
return False
818819
return True
819820

@@ -837,7 +838,10 @@ def fix_object_dict(object_dict: Dict, class_name: Optional[str] = None):
837838
k == "name" and class_name == "StyledTextTag"
838839
):
839840
if isinstance(v, str):
840-
d_out[k] = {"_class": f"{class_name}Type", "string": _(v)}
841+
if class_name == "Family":
842+
d_out[k] = {"_class": f"{class_name}RelType", "string": _(v)}
843+
else:
844+
d_out[k] = {"_class": f"{class_name}Type", "string": _(v)}
841845
else:
842846
d_out[k] = v
843847
elif k == "role":
@@ -861,6 +865,8 @@ def fix_object_dict(object_dict: Dict, class_name: Optional[str] = None):
861865
else item
862866
for item in v
863867
]
868+
elif k in ["complete"]:
869+
pass
864870
else:
865871
d_out[k] = v
866872
return d_out

0 commit comments

Comments
 (0)