(layout, placeholder, user=None, workspace=None,
                position=None, occupied_cells=[], sort_items=True)
return registered_widgets
Get widgets.

    In case if in restricted mode (``RESTRICT_PLUGIN_ACCESS`` is set to True),
    user argument should be provided. Based on it, the list of plugins is
    returned.  Restrictions are bypassed in case if ``RESTRICT_PLUGIN_ACCESS``
    is set to False or user given is a superuser.

    Placeholders are validated already. We don't need to have validation here.

    :param dash.base.BaseDashLayout layout: Layout object.
    :param string placeholder: Placeholder uid.
    :param django.contrib.auth.models.User user:
    :param string workspace: Workspace slug.
    :param int position: Plugin position.
    :param list occupied_cells: List of already occupied cells.
    :param bool sort_items: If set to True, returned items are sorted.
    :return list:
Get widgets.
Get widgets .
def get_widgets(layout, placeholder, user=None, workspace=None,
                position=None, occupied_cells=[], sort_items=True):
    """Get widgets.

    In case if in restricted mode (``RESTRICT_PLUGIN_ACCESS`` is set to True),
    user argument should be provided. Based on it, the list of plugins is
    returned.  Restrictions are bypassed in case if ``RESTRICT_PLUGIN_ACCESS``
    is set to False or user given is a superuser.

    Placeholders are validated already. We don't need to have validation here.

    :param dash.base.BaseDashLayout layout: Layout object.
    :param string placeholder: Placeholder uid.
    :param django.contrib.auth.models.User user:
    :param string workspace: Workspace slug.
    :param int position: Plugin position.
    :param list occupied_cells: List of already occupied cells.
    :param bool sort_items: If set to True, returned items are sorted.
    :return list:
    """
    # We should get the layout, see loop through its' plugins and see which of
    # those do have renderers. Then we get all the plugins (based on whether
    # they are restricted or not - get the list) and then filter out those
    # that do not have renderers.

    ensure_autodiscover()

    registered_widgets = {}

    plugin_widget_uids = plugin_widget_registry._registry.keys()

    if not RESTRICT_PLUGIN_ACCESS or getattr(user, 'is_superuser', False):
        for uid, plugin in plugin_registry._registry.items():
            # We should make sure that there are widgets available for the
            # placeholder.
            plugin_widget_uid = PluginWidgetRegistry.namify(
                layout.uid,
                placeholder.uid,
                uid
            )

            # Get cells occupied by plugin widget.
            widget_occupied_cells = get_occupied_cells(
                layout,
                placeholder,
                uid,
                position,
                check_boundaries=True
            )

            if plugin_widget_uid in plugin_widget_uids \
               and widget_occupied_cells is not False \
               and not lists_overlap(widget_occupied_cells, occupied_cells):

                plugin_widget = plugin_widget_registry.get(plugin_widget_uid)
                kwargs = {
                    'placeholder_uid': placeholder.uid,
                    'plugin_uid': uid
                }
                if workspace:
                    kwargs.update({'workspace': workspace})
                if position:
                    kwargs.update({'position': position})

                plugin_group = safe_text(plugin.group)
                if plugin_group not in registered_widgets:
                    registered_widgets[plugin_group] = []

                widget_name = safe_text(plugin.name)

                registered_widgets[plugin_group].append(
                    (
                        uid,
                        '{0} ({1}x{2})'.format(widget_name,
                                               plugin_widget.cols,
                                               plugin_widget.rows),
                        reverse('dash.add_dashboard_entry', kwargs=kwargs)
                    )
                )
    else:
        allowed_plugin_uids = get_allowed_plugin_uids(user)

        for uid, plugin in plugin_registry._registry.items():
            # We should make sure that there are widgets available for the
            # placeholder and user has access to the widget desired.
            plugin_widget_uid = PluginWidgetRegistry.namify(
                layout.uid,
                placeholder.uid,
                uid
            )

            # Get cells occupied by plugin widget.
            widget_occupied_cells = get_occupied_cells(
                layout,
                placeholder,
                uid,
                position,
                check_boundaries=True
            )

            if uid in allowed_plugin_uids \
               and plugin_widget_uid in plugin_widget_uids \
               and widget_occupied_cells is not False \
               and not lists_overlap(widget_occupied_cells, occupied_cells):

                plugin_widget = plugin_widget_registry.get(plugin_widget_uid)
                kwargs = {
                    'placeholder_uid': placeholder.uid,
                    'plugin_uid': uid
                }
                if workspace:
                    kwargs.update({'workspace': workspace})
                if position:
                    kwargs.update({'position': position})

                plugin_group = safe_text(plugin.group)
                if plugin_group not in registered_widgets:
                    registered_widgets[plugin_group] = []

                registered_widgets[plugin_group].append(
                    (
                        uid,
                        '{0} ({1}x{2})'.format(safe_text(plugin.name),
                                               plugin_widget.cols,
                                               plugin_widget.rows),
                        reverse('dash.add_dashboard_entry', kwargs=kwargs)
                    )
                )

    if sort_items:
        for key, prop in registered_widgets.items():
            prop.sort()

    return registered_widgets
def get_widgets ( layout , placeholder , user = None , workspace = None , position = None , occupied_cells = [ ] , sort_items = True ) : # We should get the layout, see loop through its' plugins and see which of # those do have renderers. Then we get all the plugins (based on whether # they are restricted or not - get the list) and then filter out those # that do not have renderers. ensure_autodiscover ( ) registered_widgets = { } plugin_widget_uids = plugin_widget_registry . _registry . keys ( ) if not RESTRICT_PLUGIN_ACCESS or getattr ( user , 'is_superuser' , False ) : for uid , plugin in plugin_registry . _registry . items ( ) : # We should make sure that there are widgets available for the # placeholder. plugin_widget_uid = PluginWidgetRegistry . namify ( layout . uid , placeholder . uid , uid ) # Get cells occupied by plugin widget. widget_occupied_cells = get_occupied_cells ( layout , placeholder , uid , position , check_boundaries = True ) if plugin_widget_uid in plugin_widget_uids and widget_occupied_cells is not False and not lists_overlap ( widget_occupied_cells , occupied_cells ) : plugin_widget = plugin_widget_registry . get ( plugin_widget_uid ) kwargs = { 'placeholder_uid' : placeholder . uid , 'plugin_uid' : uid } if workspace : kwargs . update ( { 'workspace' : workspace } ) if position : kwargs . update ( { 'position' : position } ) plugin_group = safe_text ( plugin . group ) if plugin_group not in registered_widgets : registered_widgets [ plugin_group ] = [ ] widget_name = safe_text ( plugin . name ) registered_widgets [ plugin_group ] . append ( ( uid , '{0} ({1}x{2})' . format ( widget_name , plugin_widget . cols , plugin_widget . rows ) , reverse ( 'dash.add_dashboard_entry' , kwargs = kwargs ) ) ) else : allowed_plugin_uids = get_allowed_plugin_uids ( user ) for uid , plugin in plugin_registry . _registry . items ( ) : # We should make sure that there are widgets available for the # placeholder and user has access to the widget desired. plugin_widget_uid = PluginWidgetRegistry . namify ( layout . uid , placeholder . uid , uid ) # Get cells occupied by plugin widget. widget_occupied_cells = get_occupied_cells ( layout , placeholder , uid , position , check_boundaries = True ) if uid in allowed_plugin_uids and plugin_widget_uid in plugin_widget_uids and widget_occupied_cells is not False and not lists_overlap ( widget_occupied_cells , occupied_cells ) : plugin_widget = plugin_widget_registry . get ( plugin_widget_uid ) kwargs = { 'placeholder_uid' : placeholder . uid , 'plugin_uid' : uid } if workspace : kwargs . update ( { 'workspace' : workspace } ) if position : kwargs . update ( { 'position' : position } ) plugin_group = safe_text ( plugin . group ) if plugin_group not in registered_widgets : registered_widgets [ plugin_group ] = [ ] registered_widgets [ plugin_group ] . append ( ( uid , '{0} ({1}x{2})' . format ( safe_text ( plugin . name ) , plugin_widget . cols , plugin_widget . rows ) , reverse ( 'dash.add_dashboard_entry' , kwargs = kwargs ) ) ) if sort_items : for key , prop in registered_widgets . items ( ) : prop . sort ( ) return registered_widgets