@@ -335,7 +335,12 @@ def get_folder_by_id(self, project_id: int, folder_id: int):
335335 exclude = {"completedCount" , "is_root" }
336336 )
337337
338- def get_item_by_id (self , project_id : int , item_id : int ):
338+ def get_item_by_id (
339+ self ,
340+ project_id : int ,
341+ item_id : int ,
342+ include : List [Literal ["custom_metadata" , "categories" ]] = None ,
343+ ):
339344 """Returns the item metadata
340345
341346 :param project_id: the id of the project
@@ -344,16 +349,50 @@ def get_item_by_id(self, project_id: int, item_id: int):
344349 :param item_id: the id of the item
345350 :type item_id: int
346351
352+ :param include: Specifies additional fields to include in the response.
353+
354+ Possible values are
355+
356+ - "custom_metadata": Includes custom metadata attached to the item.
357+ - "categories": Includes categories attached to the item.
358+ :type include: list of str, optional
359+
347360 :return: item metadata
348361 :rtype: dict
349362 """
350363 project_response = self .controller .get_project_by_id (project_id = project_id )
351364 project_response .raise_for_status ()
352- item = self .controller .get_item_by_id (
353- item_id = item_id , project = project_response .data
365+
366+ if (
367+ include
368+ and "categories" in include
369+ and project_response .data .type != ProjectType .MULTIMODAL .value
370+ ):
371+ raise AppException (
372+ "The 'categories' option in the 'include' field is only supported for Multimodal projects."
373+ )
374+
375+ # always join assignments for all project types
376+ _include = {"assignments" }
377+ if include :
378+ _include .update (set (include ))
379+ include = list (_include )
380+
381+ include_custom_metadata = "custom_metadata" in include
382+ if include_custom_metadata :
383+ include .remove ("custom_metadata" )
384+
385+ item = self .controller .items .get_item_by_id (
386+ item_id = item_id , project = project_response .data , include = include
354387 )
355388
356- return BaseSerializer (item ).serialize (exclude = {"url" , "meta" })
389+ if include_custom_metadata :
390+ item_custom_fields = self .controller .custom_fields .list_fields (
391+ project = project_response .data , item_ids = [item .id ]
392+ )
393+ item .custom_metadata = item_custom_fields [item .id ]
394+
395+ return BaseSerializer (item ).serialize (exclude = {"url" , "meta" }, by_alias = False )
357396
358397 def get_team_metadata (self , include : List [Literal ["scores" ]] = None ):
359398 """
@@ -2102,15 +2141,10 @@ def assign_folder(
21022141 if response .errors :
21032142 raise AppException (response .errors )
21042143 project = response .data
2105- response = self .controller .projects . get_metadata (
2106- project = project , include_contributors = True
2144+ project_contributors = self .controller .work_management . list_users (
2145+ project = project
21072146 )
2108-
2109- if response .errors :
2110- raise AppException (response .errors )
2111-
2112- contributors = response .data .users
2113- verified_users = [i .user_id for i in contributors ]
2147+ verified_users = [i .email for i in project_contributors ]
21142148 verified_users = set (users ).intersection (set (verified_users ))
21152149 unverified_contributor = set (users ) - verified_users
21162150
@@ -4161,7 +4195,7 @@ def list_projects(
41614195
41624196 :param filters: Specifies filtering criteria, with all conditions combined using logical AND.
41634197
4164- - Only users matching all filter conditions are returned.
4198+ - Only projects matching all filter conditions are returned.
41654199
41664200 - If no filter operation is provided, an exact match is applied.
41674201
@@ -4195,7 +4229,7 @@ def list_projects(
41954229 Custom Fields Filtering:
41964230
41974231 - Custom fields must be prefixed with `custom_field__`.
4198- - Example: custom_field__Due_date__gte="1738281600" (filtering users whose Due_date is after the given Unix timestamp).
4232+ - Example: custom_field__Due_date__gte="1738281600" (filtering projects whose Due_date is after the given Unix timestamp).
41994233 - If include does not include “custom_fields” but filter contains ‘custom_field’, an error will be returned
42004234
42014235 - **Text** custom field only works with the following filter params: __in, __notin, __contains
@@ -5237,7 +5271,7 @@ def item_context(
52375271 "This function is only supported for Multimodal projects."
52385272 )
52395273 if isinstance (item , int ):
5240- _item = self .controller .get_item_by_id (item_id = item , project = project )
5274+ _item = self .controller .items . get_item_by_id (item_id = item , project = project )
52415275 else :
52425276 items = self .controller .items .list_items (project , folder , name = item )
52435277 if not items :
0 commit comments