(params, record_uid)
| 1361 | |
| 1362 | |
| 1363 | def enumerate_record_access_paths(params, record_uid): |
| 1364 | # type: (KeeperParams, str) -> collections.Iterable[dict] |
| 1365 | |
| 1366 | if record_uid in params.meta_data_cache: |
| 1367 | rmd = params.meta_data_cache[record_uid] |
| 1368 | yield { |
| 1369 | 'record_uid': record_uid, |
| 1370 | 'can_edit': rmd.get('can_edit') or False, |
| 1371 | 'can_share': rmd.get('can_share') or False, |
| 1372 | 'can_view': True |
| 1373 | } |
| 1374 | |
| 1375 | for sf_uid in params.shared_folder_cache: |
| 1376 | sf = params.shared_folder_cache[sf_uid] |
| 1377 | if 'records' in sf: |
| 1378 | sfrs = [x for x in sf['records'] if x['record_uid'] == record_uid] |
| 1379 | if len(sfrs) > 0: |
| 1380 | sfr = sfrs[0] |
| 1381 | is_owner = sfr.get('owner') is True |
| 1382 | if is_owner: |
| 1383 | can_edit = True |
| 1384 | can_share = True |
| 1385 | else: |
| 1386 | can_edit = sfr['can_edit'] |
| 1387 | can_share = sfr['can_share'] |
| 1388 | if 'key_type' in sf: |
| 1389 | yield { |
| 1390 | 'record_uid': record_uid, |
| 1391 | 'shared_folder_uid': sf_uid, |
| 1392 | 'can_edit': can_edit, |
| 1393 | 'can_share': can_share, |
| 1394 | 'can_view': True |
| 1395 | } |
| 1396 | else: |
| 1397 | if 'teams' in sf: |
| 1398 | for sf_team in sf['teams']: |
| 1399 | team_uid = sf_team['team_uid'] |
| 1400 | if team_uid in params.team_cache: |
| 1401 | team = params.team_cache[team_uid] |
| 1402 | yield { |
| 1403 | 'record_uid': record_uid, |
| 1404 | 'shared_folder_uid': sf_uid, |
| 1405 | 'team_uid': team_uid, |
| 1406 | 'can_edit': can_edit and not team['restrict_edit'], |
| 1407 | 'can_share': can_share and not team['restrict_share'], |
| 1408 | 'can_view': not team['restrict_view'] |
| 1409 | } |
| 1410 | |
| 1411 | |
| 1412 | def get_record_shares(params, record_uids, is_share_admin=False): |
no test coverage detected