Skip to content

Widgets

find_all_widgets(container, **params) ¤

Find and return all widgets in the container that respect the filters

Parameters:

Name Type Description Default
container Dict[str, Any]

The container of the widgets, that could be a content, community, the components of a content or the template of a content

required

Kwargs

params: params to filter on (eg, widgetType='video' will find athe first video widget in the given container)

Returns:

Type Description
List[Dict[str, Any]]

The list of all found widgets

Source code in lumapps/api/helpers/widgets.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def find_all_widgets(
    container: Dict[str, Any], **params: Dict[str, Any]
) -> List[Dict[str, Any]]:
    """ Find and return all widgets in the container that respect the filters

        Args:
            container: The container of the widgets, that could be a content, community,
                the components of a content or the template of a content

        Kwargs:
            params: params to filter on (eg, widgetType='video' will find athe first video widget in the given container)

        Returns:
            The list of all found widgets
    """  # noqa
    return list(w for w, _ in iter_widgets_and_containers(container, **params))

find_widget(container, **params) ¤

Find and return the first widget in the container that respect the filters

Parameters:

Name Type Description Default
container Dict[str, Any]

The container of the widgets, that could be a content, community, the components of a content or the template of a content

required

Kwargs

params: params to filter on (eg, widgetType='video' will find athe first video widget in the given container)

Returns:

Type Description
Optional[Dict[str, Any]]

The first found widget

Source code in lumapps/api/helpers/widgets.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
def find_widget(
    container: Dict[str, Any], **params: Dict[str, Any]
) -> Optional[Dict[str, Any]]:
    """ Find and return the first widget in the container that respect the filters

        Args:
            container: The container of the widgets, that could be a content, community,
                the components of a content or the template of a content

        Kwargs:
            params: params to filter on (eg, widgetType='video' will find athe first video widget in the given container)

        Returns:
            The first found widget
    """  # noqa
    for w, _ in iter_widgets_and_containers(container, **params):
        return w
    return None