(params, record_uid)
| 1386 | |
| 1387 | |
| 1388 | def enumerate_record_access_paths(params, record_uid): |
| 1389 | # type: (KeeperParams, str) -> collections.Iterable[dict] |
| 1390 | |
| 1391 | if record_uid in params.meta_data_cache: |
| 1392 | rmd = params.meta_data_cache[record_uid] |
| 1393 | yield { |
| 1394 | 'record_uid': record_uid, |
| 1395 | 'can_edit': rmd.get('can_edit') or False, |
| 1396 | 'can_share': rmd.get('can_share') or False, |
| 1397 | 'can_view': True |
| 1398 | } |
| 1399 | |
| 1400 | for sf_uid in params.shared_folder_cache: |
| 1401 | sf = params.shared_folder_cache[sf_uid] |
| 1402 | if 'records' in sf: |
| 1403 | sfrs = [x for x in sf['records'] if x['record_uid'] == record_uid] |
| 1404 | if len(sfrs) > 0: |
| 1405 | sfr = sfrs[0] |
| 1406 | is_owner = sfr.get('owner') is True |
| 1407 | if is_owner: |
| 1408 | can_edit = True |
| 1409 | can_share = True |
| 1410 | else: |
| 1411 | can_edit = sfr['can_edit'] |
| 1412 | can_share = sfr['can_share'] |
| 1413 | if 'key_type' in sf: |
| 1414 | yield { |
| 1415 | 'record_uid': record_uid, |
| 1416 | 'shared_folder_uid': sf_uid, |
| 1417 | 'can_edit': can_edit, |
| 1418 | 'can_share': can_share, |
| 1419 | 'can_view': True |
| 1420 | } |
| 1421 | else: |
| 1422 | if 'teams' in sf: |
| 1423 | for sf_team in sf['teams']: |
| 1424 | team_uid = sf_team['team_uid'] |
| 1425 | if team_uid in params.team_cache: |
| 1426 | team = params.team_cache[team_uid] |
| 1427 | yield { |
| 1428 | 'record_uid': record_uid, |
| 1429 | 'shared_folder_uid': sf_uid, |
| 1430 | 'team_uid': team_uid, |
| 1431 | 'can_edit': can_edit and not team['restrict_edit'], |
| 1432 | 'can_share': can_share and not team['restrict_share'], |
| 1433 | 'can_view': not team['restrict_view'] |
| 1434 | } |
| 1435 | |
| 1436 | |
| 1437 | def get_record_shares(params, record_uids, is_share_admin=False): |
no test coverage detected