|
@@ -467,6 +467,24 @@ class ContentApi(object):
|
467
|
467
|
|
468
|
468
|
return resultset.all()
|
469
|
469
|
|
|
470
|
+ def get_children(self, parent_id: int, content_types: list, workspace: Workspace=None) -> [Content]:
|
|
471
|
+ """
|
|
472
|
+ Return parent_id childs of given content_types
|
|
473
|
+ :param parent_id: parent id
|
|
474
|
+ :param content_types: list of types
|
|
475
|
+ :param workspace: workspace filter
|
|
476
|
+ :return: list of content
|
|
477
|
+ """
|
|
478
|
+ resultset = self._base_query(workspace)
|
|
479
|
+ resultset = resultset.filter(Content.type.in_(content_types))
|
|
480
|
+
|
|
481
|
+ if parent_id:
|
|
482
|
+ resultset = resultset.filter(Content.parent_id==parent_id)
|
|
483
|
+ if parent_id is False:
|
|
484
|
+ resultset = resultset.filter(Content.parent_id == None)
|
|
485
|
+
|
|
486
|
+ return resultset.all()
|
|
487
|
+
|
470
|
488
|
# TODO find an other name to filter on is_deleted / is_archived
|
471
|
489
|
def get_all_with_filter(self, parent_id: int=None, content_type: str=ContentType.Any, workspace: Workspace=None) -> [Content]:
|
472
|
490
|
assert parent_id is None or isinstance(parent_id, int) # DYN_REMOVE
|