def get_one(self, folder_id): folder_id = int(folder_id) user = tmpl_context.current_user workspace = tmpl_context.workspace workspace_id = tmpl_context.workspace_id current_user_content = Context(CTX.CURRENT_USER, current_user=user).toDict(user) current_user_content.roles.sort(key=lambda role: role.workspace.name) content_api = ContentApi(user) folder = content_api.get_one(folder_id, ContentType.Folder, workspace) fake_api_breadcrumb = self.get_breadcrumb(folder_id) fake_api_subfolders = self.get_all_fake(workspace, folder.content_id).result fake_api_pages = self.pages.get_all_fake(workspace, folder).result fake_api_files = self.files.get_all_fake(workspace, folder).result fake_api_threads = self.threads.get_all_fake(workspace, folder).result fake_api_content = DictLikeClass( current_user=current_user_content, breadcrumb=fake_api_breadcrumb, current_folder_subfolders=fake_api_subfolders, current_folder_pages=fake_api_pages, current_folder_files=fake_api_files, current_folder_threads=fake_api_threads, ) fake_api = Context(CTX.FOLDER).toDict(fake_api_content) sub_items = content_api.get_children( parent_id=folder.content_id, content_types=[ ContentType.Folder, ContentType.File, ContentType.Page, ContentType.Thread, ], ) fake_api.sub_items = Context(CTX.FOLDER_CONTENT_LIST).toDict(sub_items) fake_api.content_types = Context(CTX.DEFAULT).toDict( content_api.get_all_types()) dictified_folder = Context(CTX.FOLDER).toDict(folder, 'folder') return DictLikeClass(result=dictified_folder, fake_api=fake_api)
def get_one(self, folder_id, **kwargs): """ :param folder_id: Displayed folder id :param kwargs: * show_deleted: bool: Display deleted contents or hide them if False * show_archived: bool: Display archived contents or hide them if False """ show_deleted = str_as_bool(kwargs.get('show_deleted', '')) show_archived = str_as_bool(kwargs.get('show_archived', '')) folder_id = int(folder_id) user = tmpl_context.current_user workspace = tmpl_context.workspace current_user_content = Context(CTX.CURRENT_USER, current_user=user).toDict(user) current_user_content.roles.sort(key=lambda role: role.workspace.name) content_api = ContentApi( user, show_deleted=show_deleted, show_archived=show_archived, ) with content_api.show(show_deleted=True, show_archived=True): folder = content_api.get_one( folder_id, ContentType.Folder, workspace, ) fake_api_breadcrumb = self.get_breadcrumb(folder_id) fake_api_subfolders = self.get_all_fake(workspace, folder.content_id).result fake_api_pages = self.pages.get_all_fake(workspace, folder).result fake_api_files = self.files.get_all_fake(workspace, folder).result fake_api_threads = self.threads.get_all_fake(workspace, folder).result fake_api_content = DictLikeClass( current_user=current_user_content, breadcrumb=fake_api_breadcrumb, current_folder_subfolders=fake_api_subfolders, current_folder_pages=fake_api_pages, current_folder_files=fake_api_files, current_folder_threads=fake_api_threads, ) fake_api = Context(CTX.FOLDER).toDict(fake_api_content) sub_items = content_api.get_children( parent_id=folder.content_id, content_types=[ ContentType.Folder, ContentType.File, ContentType.Page, ContentType.Thread, ], ) fake_api.sub_items = Context(CTX.FOLDER_CONTENT_LIST).toDict(sub_items) fake_api.content_types = Context(CTX.DEFAULT).toDict( content_api.get_all_types()) dictified_folder = Context(CTX.FOLDER).toDict(folder, 'folder') return DictLikeClass( result=dictified_folder, fake_api=fake_api, show_deleted=show_deleted, show_archived=show_archived, )