Ejemplo n.º 1
0
def createNewDashboard(userId, name):
    """
    Creates a new dashboard for the user
    """
    if Dashboard.objects(analystId=userId,name=name):
        return
    newDash = Dashboard()
    newDash.name = name
    newDash.analystId = userId
    newDash.save()
    return newDash
Ejemplo n.º 2
0
def cloneDashboard(userId, dashboard, cloneSearches=False, skip=None):
    """
    Clones a public dashboard to a user-modified version of if.
    cloneSearches will clone all affiliated searches with the dashboard.
    Skip will skip a specific table if cloning searches
    """
    if Dashboard.objects(analystId=userId,name=dashboard.name):
        return
    newDash = Dashboard()
    newDash.name = dashboard.name
    newDash.theme = dashboard.theme
    newDash.analystId = userId
    newDash.parent = dashboard.id
    newDash.save()
    if cloneSearches:
        for search in SavedSearch.objects(dashboard = dashboard.id):
            if skip != str(search.id):
                cloneSavedSearch(search, newDash.id)
    return newDash