Return structured NSF folder share perms and a compact text suffix. Owner is listed under ``users`` with permission ``OW`` (not a separate label). Applications are listed separately (never as fake user emails / UIDs).
(params, folder_uid, *, include_uids=False)
| 1994 | |
| 1995 | |
| 1996 | def _nsf_folder_share_data(params, folder_uid, *, include_uids=False): |
| 1997 | """Return structured NSF folder share perms and a compact text suffix. |
| 1998 | |
| 1999 | Owner is listed under ``users`` with permission ``OW`` (not a separate label). |
| 2000 | Applications are listed separately (never as fake user emails / UIDs). |
| 2001 | """ |
| 2002 | from .. import nested_share_folder as _nsf |
| 2003 | accessors = _nsf.get_nsf_folder_share_accessors(params, folder_uid) |
| 2004 | folder_info = (getattr(params, 'nested_share_folders', {}) or {}).get(folder_uid) or {} |
| 2005 | owner = (folder_info.get('owner_username') or '').strip() |
| 2006 | if owner and _looks_like_uid(owner): |
| 2007 | owner = '' |
| 2008 | users = [] |
| 2009 | teams = [] |
| 2010 | applications = [] |
| 2011 | user_parts = [] |
| 2012 | team_parts = [] |
| 2013 | app_parts = [] |
| 2014 | seen_users = set() |
| 2015 | |
| 2016 | if owner: |
| 2017 | users.append({'email': owner, 'permissions': ['OW']}) |
| 2018 | user_parts.append(f'[{owner}:OW]') |
| 2019 | seen_users.add(owner.lower()) |
| 2020 | |
| 2021 | for a in accessors: |
| 2022 | at = a.get('access_type') or '' |
| 2023 | abbrev = _nsf_role_abbrev(a) |
| 2024 | auid = a.get('accessor_uid') or '' |
| 2025 | |
| 2026 | if at == 'AT_OWNER': |
| 2027 | if not owner: |
| 2028 | email = _resolve_nsf_user_email(params, a) |
| 2029 | if email and email.lower() not in seen_users: |
| 2030 | users.append({'email': email, 'permissions': ['OW']}) |
| 2031 | user_parts.append(f'[{email}:OW]') |
| 2032 | seen_users.add(email.lower()) |
| 2033 | continue |
| 2034 | |
| 2035 | if at == 'AT_TEAM': |
| 2036 | name = _resolve_tree_team_name(params, auid) |
| 2037 | entry = {'name': name, 'permissions': [abbrev]} |
| 2038 | if include_uids and auid: |
| 2039 | entry['uid'] = auid |
| 2040 | teams.append(entry) |
| 2041 | team_parts.append(f'[{name}:{abbrev}]') |
| 2042 | continue |
| 2043 | |
| 2044 | if at == 'AT_APPLICATION': |
| 2045 | app_name = _resolve_nsf_app_name(params, auid) or (auid if include_uids else 'application') |
| 2046 | entry = {'name': app_name, 'permissions': [abbrev]} |
| 2047 | if include_uids and auid: |
| 2048 | entry['uid'] = auid |
| 2049 | applications.append(entry) |
| 2050 | app_parts.append(f'[{app_name}:{abbrev}]') |
| 2051 | continue |
| 2052 | |
| 2053 | if at in ('AT_USER', 'AT_UNKNOWN', ''): |