Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: not all permissions should be sent to server after update - only the modified ones #45

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dsp_permissions_scripts/oap/oap_get_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ def apply_updated_oaps_on_server(
shortcode: str,
) -> None:
"""Applies object access permissions on a DSP server."""
logger.info("******* Applying updated object access permissions on server *******")
print(f"{get_timestamp()}: ******* Applying updated object access permissions on server *******")
logger.info(f"******* Updating OAPs of {len(resource_oaps)} resources on {host} *******")
print(f"{get_timestamp()}: ******* Updating OAPs of {len(resource_oaps)} resources on {host} *******")
failed_res_iris: list[str] = []
for index, resource_oap in enumerate(resource_oaps):
msg = f"Updating permissions of resource {index + 1}/{len(resource_oaps)}: {resource_oap.object_iri}..."
Expand Down
12 changes: 9 additions & 3 deletions dsp_permissions_scripts/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,33 @@

def modify_aps(aps: list[Ap]) -> list[Ap]:
"""Adapt this sample to your needs."""
modified_aps = []
for ap in aps:
if ap.forGroup == builtin_groups.PROJECT_MEMBER:
if ApValue.ProjectAdminOntologyAllPermission not in ap.hasPermissions:
ap.add_permission(ApValue.ProjectAdminOntologyAllPermission)
return aps
modified_aps.append(ap)
return modified_aps


def modify_doaps(doaps: list[Doap]) -> list[Doap]:
"""Adapt this sample to your needs."""
modified_doaps = []
for doap in doaps:
if doap.target.group in [builtin_groups.PROJECT_MEMBER, builtin_groups.PROJECT_ADMIN]:
doap.scope = PUBLIC
return doaps
modified_doaps.append(doap)
return modified_doaps


def modify_oaps(oaps: list[Oap]) -> list[Oap]:
"""Adapt this sample to your needs."""
modified_oaps = []
for oap in oaps:
if builtin_groups.SYSTEM_ADMIN not in oap.scope.CR:
oap.scope = oap.scope.add("CR", builtin_groups.SYSTEM_ADMIN)
return oaps
modified_oaps.append(oap)
return modified_oaps


def update_aps(
Expand Down