Skip to content

Commit c16a656

Browse files
jens-kuertenJens Kürten
and
Jens Kürten
authored
Fix: Objects are not correctly attached to Engineering Change fields (#28)
--------- Co-authored-by: Jens Kürten <[email protected]>
1 parent f20c327 commit c16a656

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

csfunctions/handler.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,17 @@ def link_objects(event: Event):
6868
# e.g. all parts would be in Event.data.parts = list[Part]
6969

7070
for field_name in data.model_fields_set:
71-
# go through each field in data and look for fields that are lists
72-
# objects will always be passed in a list
71+
# go through each field in data and look for fields that are lists of BaseObjects
72+
# or direct BaseObjects
7373

7474
field = getattr(data, field_name)
7575
if isinstance(field, list):
7676
for obj in field:
7777
# the list might contain entries that are not objects, so we check first
7878
if isinstance(obj, BaseObject):
7979
obj.link_objects(data)
80+
elif isinstance(field, BaseObject):
81+
field.link_objects(data)
8082

8183

8284
def execute(function_name: str, request_body: str, function_dir: str = "src") -> str:

0 commit comments

Comments
 (0)