Find all top Shared Folders that will contain this record. Record can be in more than two folders by having a "link" which will present a record as a record with the same UID in more than one folder.
(params, record_uid)
| 47 | |
| 48 | |
| 49 | def find_parent_top_folder(params, record_uid): |
| 50 | |
| 51 | """ |
| 52 | Find all top Shared Folders that will contain this record. |
| 53 | Record can be in more than two folders by having a "link" which |
| 54 | will present a record as a record with the same UID in more than |
| 55 | one folder. |
| 56 | """ |
| 57 | contained_folder_uids = [] |
| 58 | |
| 59 | # Get all folders that might contain the given record |
| 60 | for fuid in params.subfolder_record_cache: |
| 61 | if fuid: # record is in root folder |
| 62 | if record_uid in params.subfolder_record_cache[fuid]: |
| 63 | contained_folder_uids.append(fuid) |
| 64 | |
| 65 | shared_folders_containing_record = [] |
| 66 | |
| 67 | # if records that belong to folder are found then go |
| 68 | # through each one of them to get the share folder |
| 69 | for cfuid in contained_folder_uids: |
| 70 | if cfuid: |
| 71 | folder = params.folder_cache[cfuid] |
| 72 | |
| 73 | # folder is already a shared folder |
| 74 | if isinstance(folder, SharedFolderNode): |
| 75 | shared_folders_containing_record.append(folder) |
| 76 | # folder is a sub-folder, let's get its pared shared folder |
| 77 | elif isinstance(folder, SharedFolderFolderNode): |
| 78 | shared_folder_uid = folder.shared_folder_uid |
| 79 | shared_folder = params.folder_cache[shared_folder_uid] |
| 80 | shared_folders_containing_record.append(shared_folder) |
| 81 | else: |
| 82 | logging.debug("Folder UID={} is not a shared folder".format(cfuid)) |
| 83 | |
| 84 | return shared_folders_containing_record |
| 85 | |
| 86 | |
| 87 | def contained_folders(params, folders, component): |
no test coverage detected