(workspace, for_user, request=None)
return cloned_workspace
Clone entire workspace.

    :param dash.models.DashboardWorkspace workspace:
    :param django.contrib.auth.models.User for_user:
    :param django.http.HttpRequest request:
    :return dash.models.DashboardWorkspace: Cloned workspace instance.
Clone entire workspace.
Clone entire workspace .
def clone_workspace(workspace, for_user, request=None):
    """Clone entire workspace.

    :param dash.models.DashboardWorkspace workspace:
    :param django.contrib.auth.models.User for_user:
    :param django.http.HttpRequest request:
    :return dash.models.DashboardWorkspace: Cloned workspace instance.
    """
    # Cloning workspace object.
    cloned_workspace = copy.copy(workspace)
    cloned_workspace.pk = None
    cloned_workspace.user = for_user
    cloned_workspace.is_public = False
    cloned_workspace.is_cloneable = False
    cloned_workspace.name = "{0} cloned on {1}".format(
        cloned_workspace.name,
        datetime.datetime.now()
    )

    cloned_workspace.save()

    # Cloning workspace entries.
    dashboard_entries = DashboardEntry._default_manager \
                                      .filter(workspace=workspace)

    buf = []

    for dashboard_entry in dashboard_entries:
        cloned_plugin_data = clone_plugin_data(dashboard_entry,
                                               request=request)
        cloned_dashboard_entry = DashboardEntry(
            user=for_user,
            workspace=cloned_workspace,
            layout_uid=dashboard_entry.layout_uid,
            placeholder_uid=dashboard_entry.placeholder_uid,
            plugin_uid=dashboard_entry.plugin_uid,
            plugin_data=cloned_plugin_data,
            position=dashboard_entry.position,
        )

        buf.append(cloned_dashboard_entry)

    DashboardEntry._default_manager.bulk_create(buf)

    return cloned_workspace
def clone_workspace ( workspace , for_user , request = None ) : # Cloning workspace object. cloned_workspace = copy . copy ( workspace ) cloned_workspace . pk = None cloned_workspace . user = for_user cloned_workspace . is_public = False cloned_workspace . is_cloneable = False cloned_workspace . name = "{0} cloned on {1}" . format ( cloned_workspace . name , datetime . datetime . now ( ) ) cloned_workspace . save ( ) # Cloning workspace entries. dashboard_entries = DashboardEntry . _default_manager . filter ( workspace = workspace ) buf = [ ] for dashboard_entry in dashboard_entries : cloned_plugin_data = clone_plugin_data ( dashboard_entry , request = request ) cloned_dashboard_entry = DashboardEntry ( user = for_user , workspace = cloned_workspace , layout_uid = dashboard_entry . layout_uid , placeholder_uid = dashboard_entry . placeholder_uid , plugin_uid = dashboard_entry . plugin_uid , plugin_data = cloned_plugin_data , position = dashboard_entry . position , ) buf . append ( cloned_dashboard_entry ) DashboardEntry . _default_manager . bulk_create ( buf ) return cloned_workspace