Skip to content

Commit

Permalink
adapt scenario tanner to what needs to be done
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum committed Oct 11, 2023
1 parent 4ca4887 commit 648d4eb
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions dsp_permissions_scripts/scenario-tanner/scenario-tanner.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from dotenv import load_dotenv
from dsp_permissions_scripts.models.groups import BuiltinGroup

from dsp_permissions_scripts.models.host import Hosts
from dsp_permissions_scripts.models.oap import Oap
from dsp_permissions_scripts.utils.authentication import login
from dsp_permissions_scripts.utils.doap_get import (
get_doaps_of_project,
print_doaps_of_project,
)
from dsp_permissions_scripts.utils.doap_set import _update_doap_scope
from dsp_permissions_scripts.utils.oap import apply_updated_oaps_on_server
from dsp_permissions_scripts.utils.project import get_all_resource_oaps_of_project


Expand All @@ -31,18 +34,6 @@ def fix_scenario_tanner() -> None:
)


def fix_oaps(
host: str,
shortcode: str,
token: str,
) -> None:
all_resource_oaps = get_all_resource_oaps_of_project(
shortcode=shortcode,
host=host,
token=token,
)


def fix_doaps(
host: str,
shortcode: str,
Expand All @@ -59,7 +50,8 @@ def fix_doaps(
shortcode=shortcode,
)
for d in doaps:
d.scope.V.append("http://rdfh.ch/groups/0102/oe8-uWCgS4Wl6wfOvaFGCA")
d.scope = d.scope.remove("M", BuiltinGroup.PROJECT_MEMBER)
d.scope = d.scope.add("V", BuiltinGroup.PROJECT_MEMBER)
new_doaps = []
for d in doaps:
new_doap = _update_doap_scope(
Expand All @@ -77,5 +69,31 @@ def fix_doaps(
)


def fix_oaps(
host: str,
shortcode: str,
token: str,
) -> None:
all_resource_oaps = get_all_resource_oaps_of_project(
shortcode=shortcode,
host=host,
token=token,
)
resource_oaps_updated = modify_oaps(oaps=all_resource_oaps)
apply_updated_oaps_on_server(
resource_oaps=resource_oaps_updated,
host=host,
token=token,
)


def modify_oaps(oaps: list[Oap]) -> list[Oap]:
"""Remove ProjectMember from Modify, and add it to View."""
for oap in oaps:
oap.scope = oap.scope.remove("M", BuiltinGroup.PROJECT_MEMBER)
oap.scope = oap.scope.add("V", BuiltinGroup.PROJECT_MEMBER)
return oaps


if __name__ == "__main__":
fix_scenario_tanner()

0 comments on commit 648d4eb

Please sign in to comment.