Skip to content

Commit

Permalink
Merge pull request #40 from leelavg/arr-enum
Browse files Browse the repository at this point in the history
Support for set/get of Array of custom enums
  • Loading branch information
simzacks authored Sep 29, 2021
2 parents f9c6517 + 29705c5 commit a6a1ebc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.pyc
.pylero
.pylarion
*.egg-info*
16 changes: 10 additions & 6 deletions src/pylero/base_polarion.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,12 +604,16 @@ def _custom_getter(self, field_name):
elif csm.get("is_array"):
obj = []
# ArrayOf Polarion objects have a double list.
for inst in custom_fld.value[0]:
if csm["cls"]._cls_inner._id_field:
item_inst = csm["cls"]._cls_inner(suds_object=inst)
obj.append(getattr(item_inst, item_inst._id_field))
else:
obj.append(csm["cls"]._cls_inner(suds_object=inst))
if custom_fld.value:
for inst in custom_fld.value[0]:
if csm["cls"]._cls_inner._id_field:
item_inst = csm["cls"]._cls_inner(
suds_object=inst)
obj.append(
getattr(item_inst, item_inst._id_field))
else:
obj.append(csm["cls"]._cls_inner(
suds_object=inst))
elif csm.get("cls"):
obj = csm["cls"](suds_object=custom_fld.value)
else:
Expand Down
2 changes: 2 additions & 0 deletions src/pylero/work_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,8 @@ def get_custom_fields(cls, project_id):
None)
cls._cls_suds_map[local_name]["is_custom"] = True
cls._cls_suds_map[local_name]["control"] = cls._wi_type
if parse_type[1].startswith("Array"):
cls._cls_suds_map[local_name]["is_array"] = True
if cft.required:
cls._required_fields.append(local_name)
cls._got_custom_fields = True
Expand Down

0 comments on commit a6a1ebc

Please sign in to comment.