def getMemberList(self) -> [_DAVResource]: members = [] for content in self.content.revisions: left_side = '%s/(%d - %s) ' % (self.path, content.revision_id, content.revision_type) if self.content.type == ContentType.File: members.append(HistoryFileResource( path='%s%s' % (left_side, transform_to_display(content.file_name)), environ=self.environ, content=self.content, content_revision=content, user=self.user, session=self.session, ) ) else: members.append(HistoryOtherFile( path='%s%s' % (left_side, transform_to_display(content.file_name)), environ=self.environ, content=self.content, content_revision=content, user=self.user, session=self.session, ) ) return members
def createCollection(self, label: str) -> 'Folder': """ Create a new folder for the current workspace. As it's not possible for the user to choose which types of content are allowed in this folder, we allow allow all of them. This method return the DAVCollection created. """ if '/.deleted/' in self.path or '/.archived/' in self.path: raise DAVError(HTTP_FORBIDDEN) folder = self.content_api.create( content_type=ContentType.Folder, workspace=self.workspace, label=label, parent=self.content ) subcontent = dict( folder=True, thread=True, file=True, page=True ) self.content_api.set_allowed_content(folder, subcontent) self.content_api.save(folder) transaction.commit() return Folder('%s/%s' % (self.path, transform_to_display(label)), self.environ, folder, self.workspace)
def createCollection(self, label: str) -> 'Folder': """ Create a new folder for the current workspace. As it's not possible for the user to choose which types of content are allowed in this folder, we allow allow all of them. This method return the DAVCollection created. """ if '/.deleted/' in self.path or '/.archived/' in self.path: raise DAVError(HTTP_FORBIDDEN) folder = self.content_api.create(content_type=ContentType.Folder, workspace=self.workspace, label=label, parent=self.content) subcontent = dict(folder=True, thread=True, file=True, page=True) self.content_api.set_allowed_content(folder, subcontent) self.content_api.save(folder) transaction.commit() return Folder('%s/%s' % (self.path, transform_to_display(label)), self.environ, folder, self.workspace)
def getMemberList(self) -> [_DAVResource]: members = [] if self.content: children = self.content.children else: children = self.content_api.get_all(False, ContentType.Any, self.workspace) for content in children: if content.is_archived: content_path = '%s/%s' % (self.path, transform_to_display(content.get_label_as_file())) if content.type == ContentType.Folder: members.append(Folder(content_path, self.environ, self.workspace, content)) elif content.type == ContentType.File: self._file_count += 1 members.append(File(content_path, self.environ, content)) else: self._file_count += 1 members.append(OtherFile(content_path, self.environ, content)) if self._file_count > 0 and self.provider.show_history(): members.append( HistoryFolder( path=self.path + '/' + ".history", environ=self.environ, content=self.content, workspace=self.workspace, type=HistoryType.Standard ) ) return members
def createCollection(self, name: str): """ This method is called whenever the user wants to create a DAVCollection resource as a child (in our case, we create workspaces as this is the root). [For now] we don't allow to create new workspaces through webdav client. Though if we come to allow it, deleting the error's raise will make it possible. """ # TODO : remove comment here # raise DAVError(HTTP_FORBIDDEN) new_workspace = self.workspace_api.create_workspace(name) self.workspace_api.save(new_workspace) workspace_path = '%s%s%s' % ( self.path, '' if self.path == '/' else '/', transform_to_display(new_workspace.label)) transaction.commit() return WorkspaceResource( workspace_path, self.environ, new_workspace, user=self.user, session=self.session, )
def getMemberList(self) -> [_DAVResource]: members = [] if self.content: children = self.content.children else: children = self.content_api.get_all(False, ContentType.Any, self.workspace) for content in children: if content.is_deleted: content_path = '%s/%s' % (self.path, transform_to_display(content.get_label_as_file())) if content.type == ContentType.Folder: members.append( FolderResource( content_path, self.environ, self.workspace, content, user=self.user, session=self.session, )) elif content.type == ContentType.File: self._file_count += 1 members.append( FileResource( content_path, self.environ, content, user=self.user, session=self.session, ) ) else: self._file_count += 1 members.append( OtherFileResource( content_path, self.environ, content, user=self.user, session=self.session, )) if self._file_count > 0 and self.provider.show_history(): members.append( HistoryFolderResource( path=self.path + '/' + ".history", environ=self.environ, content=self.content, workspace=self.workspace, user=self.user, type=HistoryType.Standard, session=self.session, ) ) return members
def getMember(self, item_id) -> DAVCollection: revision = self.content_api.get_one_revision(item_id) left_side = '%s/(%d - %s) ' % (self.path, revision.revision_id, revision.revision_type) if self.content.type == ContentType.File: return HistoryFile( path='%s%s' % (left_side, transform_to_display(revision.file_name)), environ=self.environ, content=self.content, content_revision=revision) else: return HistoryOtherFile( path='%s%s' % (left_side, transform_to_display(revision.get_label_as_file())), environ=self.environ, content=self.content, content_revision=revision)
def getMember(self, content_label) -> _DAVResource: content = self.content_api.get_one_by_label_and_parent( content_label=content_label, content_parent=self.content) return self.provider.getResourceInst( path=self.path + '/' + transform_to_display(content.get_label_as_file()), environ=self.environ)
def getMember(self, content_label) -> _DAVResource: content = self.content_api.get_one_by_label_and_parent( content_label=content_label, content_parent=self.content ) return self.provider.getResourceInst( path=self.path + '/' + transform_to_display(content.get_label_as_file()), environ=self.environ )
def getMemberList(self) -> [_DAVResource]: members = [] content_api = ContentApi(self.user) visible_children = content_api.get_all( self.content.content_id, ContentType.Any, self.workspace, ) for content in visible_children: content_path = '%s/%s' % ( self.path, transform_to_display(content.get_label_as_file())) try: if content.type == ContentType.Folder: members.append( Folder(content_path, self.environ, self.workspace, content)) elif content.type == ContentType.File: self._file_count += 1 members.append(File(content_path, self.environ, content)) else: self._file_count += 1 members.append( OtherFile(content_path, self.environ, content)) except Exception as exc: logger.exception( 'Unable to construct member {}'.format(content_path, ), exc_info=True, ) if self._file_count > 0 and self.provider.show_history(): members.append( HistoryFolder(path=self.path + '/' + ".history", environ=self.environ, content=self.content, workspace=self.workspace, type=HistoryType.Standard)) if self.provider.show_delete(): members.append( DeletedFolder(path=self.path + '/' + ".deleted", environ=self.environ, content=self.content, workspace=self.workspace)) if self.provider.show_archive(): members.append( ArchivedFolder(path=self.path + '/' + ".archived", environ=self.environ, content=self.content, workspace=self.workspace)) return members
def getMemberList(self) -> [_DAVResource]: members = [] content_api = ContentApi(self.user) visible_children = content_api.get_all( self.content.content_id, ContentType.Any, self.workspace, ) for content in visible_children: content_path = '%s/%s' % (self.path, transform_to_display(content.get_label_as_file())) if content.type == ContentType.Folder: members.append(Folder(content_path, self.environ, self.workspace, content)) elif content.type == ContentType.File: self._file_count += 1 members.append(File(content_path, self.environ, content)) else: self._file_count += 1 members.append(OtherFile(content_path, self.environ, content)) if self._file_count > 0 and self.provider.show_history(): members.append( HistoryFolder( path=self.path + '/' + ".history", environ=self.environ, content=self.content, workspace=self.workspace, type=HistoryType.Standard ) ) if self.provider.show_delete(): members.append( DeletedFolder( path=self.path + '/' + ".deleted", environ=self.environ, content=self.content, workspace=self.workspace ) ) if self.provider.show_archive(): members.append( ArchivedFolder( path=self.path + '/' + ".archived", environ=self.environ, content=self.content, workspace=self.workspace ) ) return members
def getMember(self, item_id) -> DAVCollection: revision = self.content_api.get_one_revision(item_id) left_side = '%s/(%d - %s) ' % (self.path, revision.revision_id, revision.revision_type) if self.content.type == ContentType.File: return HistoryFile( path='%s%s' % (left_side, transform_to_display(revision.file_name)), environ=self.environ, content=self.content, content_revision=revision) else: return HistoryOtherFile( path='%s%s' % (left_side, transform_to_display( revision.get_label_as_file())), environ=self.environ, content=self.content, content_revision=revision)
def getMember(self, label: str) -> DAVCollection: """ This method returns the child Workspace that corresponds to a given name Though for perfomance issue, we're not using this function anymore """ try: workspace = self.workspace_api.get_one_by_label(label) workspace_path = '%s%s%s' % (self.path, '' if self.path == '/' else '/', transform_to_display(workspace.label)) return Workspace(workspace_path, self.environ, workspace) except AttributeError: return None
def getMemberList(self) -> [_DAVResource]: members = [] for content in self.content.revisions: left_side = '%s/(%d - %s) ' % (self.path, content.revision_id, content.revision_type) if self.content.type == ContentType.File: members.append(HistoryFile( path='%s%s' % (left_side, transform_to_display(content.file_name)), environ=self.environ, content=self.content, content_revision=content) ) else: members.append(HistoryOtherFile( path='%s%s' % (left_side, transform_to_display(content.file_name)), environ=self.environ, content=self.content, content_revision=content) ) return members
def createCollection(self, name: str): """ This method is called whenever the user wants to create a DAVCollection resource as a child (in our case, we create workspaces as this is the root). [For now] we don't allow to create new workspaces through webdav client. Though if we come to allow it, deleting the error's raise will make it possible. """ # TODO : remove comment here # raise DAVError(HTTP_FORBIDDEN) new_workspace = self.workspace_api.create_workspace(name) self.workspace_api.save(new_workspace) workspace_path = '%s%s%s' % ( self.path, '' if self.path == '/' else '/', transform_to_display(new_workspace.label)) transaction.commit() return Workspace(workspace_path, self.environ, new_workspace)
def getDisplayName(self) -> str: left_side = '(%d - %s) ' % (self.content_revision.revision_id, self.content_revision.revision_type) return '%s%s' % (left_side, transform_to_display(self.content_revision.get_label_as_file()))
def getMember(self, content_label: str) -> _DAVResource: return self.provider.getResourceInst( '%s/%s' % (self.path, transform_to_display(content_label)), self.environ )
def getDisplayName(self) -> str: return transform_to_display(self.content.get_label_as_file())