Example #1
0
def _create_workspace(title, owner_id=None, is_public=False):
    """Create workspace.

    Args:
        title
        owner_id
        is_public

    Returns:
    """
    if owner_id is None:
        return Workspace(
            title=title,
            read_perm_id=str(permission_api.create_read_perm(title, "").id),
            write_perm_id=str(permission_api.create_write_perm(title, "").id),
            is_public=is_public,
        )
    else:
        return Workspace(
            title=title,
            owner=str(owner_id),
            read_perm_id=str(
                permission_api.create_read_perm(title, str(owner_id)).id),
            write_perm_id=str(
                permission_api.create_write_perm(title, str(owner_id)).id),
            is_public=is_public,
        )
    def generate_workspace(self):
        """ Generate an unique Template.

        Returns:

        """
        self.workspace_1 = Workspace(title="Workspace 1",
                                     owner='1',
                                     read_perm_id='1',
                                     write_perm_id='1').save()
        self.workspace_2 = Workspace(title="Workspace 2",
                                     owner='2',
                                     read_perm_id='2',
                                     write_perm_id='2').save()
Example #3
0
    def generate_workspace(self):
        """Generate the workspaces.

        Returns:

        """
        self.workspace_1 = Workspace(title="Workspace 1",
                                     owner="1",
                                     read_perm_id="1",
                                     write_perm_id="1").save()
        self.workspace_2 = Workspace(title="Workspace 2",
                                     owner="2",
                                     read_perm_id="2",
                                     write_perm_id="2").save()
Example #4
0
def get_all():
    """Get all workspace.

    Returns:

    """
    return Workspace.get_all()
    def generate_workspaces(self):
        """Generate the workspaces.

        Returns:

        """
        self.workspace_user1 = Workspace(title="Workspace 1",
                                         owner="1",
                                         read_perm_id="1",
                                         write_perm_id="1").save()
        self.public_workspace = Workspace(
            title="public",
            owner="1",
            read_perm_id="3",
            write_perm_id="3",
            is_public=True,
        ).save()
Example #6
0
 def mock_workspaces(version=""):
     with open(
             join(DUMP_OAI_PMH_TEST_PATH,
                  "workspaces{0}.json".format(version))) as f:
         data = f.read()
     data_json = json.loads(data)
     list_data = [Workspace(**x) for x in data_json]
     return list_data
Example #7
0
    def generate_workspace(self):
        """ Generate workspaces.

        Returns:

        """
        self.workspace_1 = Workspace(title="Workspace 1",
                                     owner='1',
                                     read_perm_id='1',
                                     write_perm_id='1').save()
        self.workspace_2 = Workspace(title="Workspace 2",
                                     owner='2',
                                     read_perm_id='2',
                                     write_perm_id='2').save()
        self.workspace_without_data = Workspace(title="Workspace 3",
                                                owner='3',
                                                read_perm_id='3',
                                                write_perm_id='3').save()
Example #8
0
def get_all_other_public_workspaces(user):
    """Get all other public workspaces.

    Args:
        user
    Returns:

    """
    return Workspace.get_all_other_public_workspaces(user.id)
Example #9
0
def get_all_public_workspaces():
    """Get all public workspaces.

    Args:

    Returns:

    """
    return Workspace.get_all_public_workspaces()
Example #10
0
def get_public_workspaces_owned_by_user(user):
    """Get the public workspaces owned the given user.

    Args:
        user

    Returns:

    """
    return Workspace.get_public_workspaces_owned_by_user_id(user.id)
Example #11
0
def get_all_by_owner(user):
    """Get all workspaces created by the given user.

    Args:
        user

    Returns:

    """
    return Workspace.get_all_by_owner(str(user.id))
Example #12
0
def get_non_public_workspace_owned_by_user(user):
    """Get the non public workspaces owned by the given user.

    Args:
        user:

    Returns:

    """
    return Workspace.get_non_public_workspace_owned_by_user_id(user.id)
Example #13
0
def get_by_id(workspace_id):
    """Return the workspace with the given id.

    Args:
        workspace_id

    Returns:
        Workspace (obj): Workspace object with the given id

    """
    return Workspace.get_by_id(workspace_id)
Example #14
0
def get_by_id_list(list_workspace_id):
    """Return a list of workspaces with the given id list.

    Args:
        list_workspace_id

    Returns:
    """
    list_workspace = []
    for workspace_id in list_workspace_id:
        list_workspace.append(Workspace.get_by_id(workspace_id))
    return list_workspace
Example #15
0
def _get_workspace():
    workspace = Workspace()
    workspace.title = "title"
    workspace.owner = 1
    workspace.is_public = True
    workspace.pk = ObjectId()
    return workspace
Example #16
0
def get_all_workspaces_with_read_access_not_owned_by_user(user):
    """Get the all workspaces with read access not owned by the given user.

    Args:
        user

    Returns:

    """
    read_permissions = permission_api.get_all_workspace_permissions_user_can_read(
        user)
    return Workspace.get_all_workspaces_with_read_access_not_owned_by_user_id(
        user.id, read_permissions)
Example #17
0
def get_all_workspaces_with_write_access_not_owned_by_user_id(user):
    """Get the all workspaces with write access not owned by the given user.

    Args:
        user

    Returns:

    """
    write_permissions = permission_api.get_all_workspace_permissions_user_can_write(
        user)
    return Workspace.get_all_workspaces_with_write_access_not_owned_by_user_id(
        user.id, write_permissions)
Example #18
0
def get_global_workspace():
    """Get global workspace.

    Return:
    """
    return Workspace.get_global_workspace()