Example #1
0
def createWorkSpace (workSpaceName, user):
    active = False
    workspaces = WorkSpace.objects.filter(users__id=user.id, active=True)
    if workspaces.count()==0:
        active = True
        
    #Workspace creation
    workspace = WorkSpace(name=workSpaceName, active=active)
    workspace.save()
    
    #Adding user reference to workspace in the many to many relationship
    workspace.users.add(user)
   
    #Tab creation
    tab_ids = createTab ('MyTab', user, workspace)
    
    # Returning created Ids
    ids = {}
    
    ids['workspace'] = {}
    
    ids['workspace']['id'] = workspace.id
    ids['workspace']['name'] = workspace.name
    
    ids['workspace']['tab'] = tab_ids

    return ids
Example #2
0
def createWorkSpace (workSpaceName, user):
    active = False
    workspaces = WorkSpace.objects.filter(users__id=user.id, active=True)
    if workspaces.count()==0:
        active = True
        
    #Workspace creation
    workspace = WorkSpace(name=workSpaceName, active=active)
    workspace.save()
    
    #Adding user reference to workspace in the many to many relationship
    workspace.users.add(user)
   
    #Tab creation
    tab_ids = createTab ('MyTab', user, workspace)
    
    # Returning created Ids
    ids = {}
    
    ids['workspace'] = {}
    
    ids['workspace']['id'] = workspace.id
    ids['workspace']['name'] = workspace.name
    
    ids['workspace']['tab'] = tab_ids

    return ids
Example #3
0
def createEmptyWorkSpace(workSpaceName, user):
    active = False
    workspaces = UserWorkSpace.objects.filter(user__id=user.id, active=True)
    if workspaces.count() == 0:
        # there isn't yet an active workspace
        active = True

    #Workspace creation
    workspace = WorkSpace(name=workSpaceName, creator=user)
    workspace.save()

    #Adding user reference to workspace in the many to many relationship
    user_workspace = UserWorkSpace(user=user, workspace=workspace, active=active)
    user_workspace.save()

    #Tab creation
    createTab('MyTab', user, workspace)

    return workspace
Example #4
0
def createEmptyWorkSpace(workSpaceName, user):
    active = False
    workspaces = UserWorkSpace.objects.filter(user__id=user.id, active=True)
    if workspaces.count() == 0:
        # there isn't yet an active workspace
        active = True

    #Workspace creation
    workspace = WorkSpace(name=workSpaceName, creator=user)
    workspace.save()

    #Adding user reference to workspace in the many to many relationship
    user_workspace = UserWorkSpace(user=user,
                                   workspace=workspace,
                                   active=active)
    user_workspace.save()

    #Tab creation
    createTab('MyTab', user, workspace)

    return workspace
Example #5
0
def createWorkSpace(workSpaceName, user):
    #Workspace creation
    workspace = WorkSpace(name=workSpaceName, active=False, user=user)
    workspace.save()

    setActiveWorkspace(user, workspace)

    #Tab creation
    tab_ids = createTab('MyTab', user, workspace)

    # Returning created Ids
    ids = {}

    ids['workspace'] = {}

    ids['workspace']['id'] = workspace.id
    ids['workspace']['name'] = workspace.name

    ids['workspace']['tab'] = tab_ids

    return ids
def buildWorkspaceFromTemplate(template, user):

    if isinstance(template, unicode):
        # Work around: ValueError: Unicode strings with encoding declaration
        # are not supported.
        template = template.encode('utf-8')

    xml = etree.fromstring(template)

    name = NAME_XPATH(xml)[0].text

    # Workspace creation
    workspace = WorkSpace(name=name, creator=user)
    workspace.save()

    # Adding user reference to workspace in the many to many relationship
    user_workspace = UserWorkSpace(user=user, workspace=workspace, active=False)
    user_workspace.save()

    fillWorkspaceUsingTemplate(workspace, template, xml)

    return (workspace, user_workspace)
Example #7
0
def createWorkSpace (workSpaceName, user):
    active = False
    workspaces = WorkSpace.objects.filter(user=user, active=True)
    if workspaces.count()==0:
        active = True
        
    #Workspace creation
    workspace = WorkSpace(name=workSpaceName, active=active, user=user)
    workspace.save()
   
    #Tab creation
    tab_ids = createTab ('MyTab', user, workspace)
    
    # Returning created Ids
    ids = {}
    
    ids['workspace'] = {}
    
    ids['workspace']['id'] = workspace.id
    ids['workspace']['name'] = workspace.name
    
    ids['workspace']['tab'] = tab_ids

    return ids
Example #8
0
def createWorkSpace(workSpaceName, user):
    active = False
    workspaces = WorkSpace.objects.filter(user=user, active=True)
    if workspaces.count() == 0:
        active = True

    #Workspace creation
    workspace = WorkSpace(name=workSpaceName, active=active, user=user)
    workspace.save()

    #Tab creation
    tab_ids = createTab('MyTab', user, workspace)

    # Returning created Ids
    ids = {}

    ids['workspace'] = {}

    ids['workspace']['id'] = workspace.id
    ids['workspace']['name'] = workspace.name

    ids['workspace']['tab'] = tab_ids

    return ids
Example #9
0
def test():
    django.setup()
    load_config()
    #print config
    #print '=' * 80
    # generate workspace
    workspace = WorkSpace()

    # 1, generate structure
    workspace_root = uuid.uuid4()
    workspace.fill('web', 'from test_gen_workspace', workspace_root)
    root_path = workspace.generate_ws_folder()

    # 2, move reference python
    lib_path = workspace.move_lib_folders()
    #print '-' * 20
    workspace.save()