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

code and logs for 0811 postcards (DEV-2932) #71

Closed
wants to merge 12 commits into from
  •  
  •  
  •  
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,3 @@ cython_debug/
.vscode

.DS_Store

project_data
72 changes: 72 additions & 0 deletions project_code/0811_postcards/postcards.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# pylint: disable=duplicate-code

from dotenv import load_dotenv

from dsp_permissions_scripts.models import builtin_groups
from dsp_permissions_scripts.models.host import Hosts
from dsp_permissions_scripts.oap.oap_get import get_all_resource_oaps_of_project
from dsp_permissions_scripts.oap.oap_model import Oap
from dsp_permissions_scripts.oap.oap_serialize import serialize_resource_oaps
from dsp_permissions_scripts.oap.oap_set import apply_updated_oaps_on_server
from dsp_permissions_scripts.utils.authentication import login


def modify_oaps(oaps: list[Oap]) -> list[Oap]:
for oap in oaps:
oap.scope = oap.scope.remove("V", builtin_groups.KNOWN_USER)
oap.scope = oap.scope.remove("V", builtin_groups.UNKNOWN_USER)
oap.scope = oap.scope.add("RV", builtin_groups.KNOWN_USER)
oap.scope = oap.scope.add("RV", builtin_groups.UNKNOWN_USER)
return oaps


def update_oaps(
host: str,
shortcode: str,
token: str,
) -> None:
resource_oaps = get_all_resource_oaps_of_project(
shortcode=shortcode,
host=host,
token=token,
)
serialize_resource_oaps(
resource_oaps=resource_oaps,
shortcode=shortcode,
mode="original",
)
resource_oaps_modified = modify_oaps(oaps=resource_oaps)
apply_updated_oaps_on_server(
resource_oaps=resource_oaps_modified,
host=host,
token=token,
shortcode=shortcode,
)
resource_oaps_updated = get_all_resource_oaps_of_project(
shortcode=shortcode,
host=host,
token=token,
)
serialize_resource_oaps(
resource_oaps=resource_oaps_updated,
shortcode=shortcode,
mode="modified",
)


def modify_postcards() -> None:
"""Adapt the project "Postkarten Russlands" on prod: Set all images to restricted."""
load_dotenv() # set login credentials from .env file as environment variables
host = Hosts.get_host("stage")
shortcode = "0811"
token = login(host)

update_oaps(
host=host,
shortcode=shortcode,
token=token,
)


if __name__ == "__main__":
modify_postcards()
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"scope": {
"CR": [
"http://www.knora.org/ontology/knora-admin#Creator",
"http://www.knora.org/ontology/knora-admin#ProjectAdmin"
],
"D": [],
"M": [],
"V": [],
"RV": [
"http://www.knora.org/ontology/knora-admin#UnknownUser",
"http://www.knora.org/ontology/knora-admin#KnownUser"
]
},
"object_iri": "http://rdfh.ch/0811/-6Ey8yMdRCKr9duuR8_OiQ"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"scope": {
"CR": [
"http://www.knora.org/ontology/knora-admin#Creator",
"http://www.knora.org/ontology/knora-admin#ProjectAdmin"
],
"D": [],
"M": [],
"V": [],
"RV": [
"http://www.knora.org/ontology/knora-admin#UnknownUser",
"http://www.knora.org/ontology/knora-admin#KnownUser"
]
},
"object_iri": "http://rdfh.ch/0811/-EQy_Rg7SSaJHpVov-1eeg"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"scope": {
"CR": [
"http://www.knora.org/ontology/knora-admin#Creator",
"http://www.knora.org/ontology/knora-admin#ProjectAdmin"
],
"D": [],
"M": [],
"V": [],
"RV": [
"http://www.knora.org/ontology/knora-admin#UnknownUser",
"http://www.knora.org/ontology/knora-admin#KnownUser"
]
},
"object_iri": "http://rdfh.ch/0811/-G8WP2CWSz6Ydkv1_FhsZw"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"scope": {
"CR": [
"http://www.knora.org/ontology/knora-admin#Creator",
"http://www.knora.org/ontology/knora-admin#ProjectAdmin"
],
"D": [],
"M": [],
"V": [],
"RV": [
"http://www.knora.org/ontology/knora-admin#UnknownUser",
"http://www.knora.org/ontology/knora-admin#KnownUser"
]
},
"object_iri": "http://rdfh.ch/0811/-Jw8rckgTGSMMgAWdSiegA"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"scope": {
"CR": [
"http://www.knora.org/ontology/knora-admin#Creator",
"http://www.knora.org/ontology/knora-admin#ProjectAdmin"
],
"D": [],
"M": [],
"V": [],
"RV": [
"http://www.knora.org/ontology/knora-admin#UnknownUser",
"http://www.knora.org/ontology/knora-admin#KnownUser"
]
},
"object_iri": "http://rdfh.ch/0811/-StUymS9Tq2hrkBPWZB9HA"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"scope": {
"CR": [
"http://www.knora.org/ontology/knora-admin#Creator",
"http://www.knora.org/ontology/knora-admin#ProjectAdmin"
],
"D": [],
"M": [],
"V": [],
"RV": [
"http://www.knora.org/ontology/knora-admin#UnknownUser",
"http://www.knora.org/ontology/knora-admin#KnownUser"
]
},
"object_iri": "http://rdfh.ch/0811/-XgZe-WQQM6TJt8FghOixw"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"scope": {
"CR": [
"http://www.knora.org/ontology/knora-admin#Creator",
"http://www.knora.org/ontology/knora-admin#ProjectAdmin"
],
"D": [],
"M": [],
"V": [],
"RV": [
"http://www.knora.org/ontology/knora-admin#UnknownUser",
"http://www.knora.org/ontology/knora-admin#KnownUser"
]
},
"object_iri": "http://rdfh.ch/0811/-csNEAXgT2i9Ujx_owRRdw"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"scope": {
"CR": [
"http://www.knora.org/ontology/knora-admin#Creator",
"http://www.knora.org/ontology/knora-admin#ProjectAdmin"
],
"D": [],
"M": [],
"V": [],
"RV": [
"http://www.knora.org/ontology/knora-admin#UnknownUser",
"http://www.knora.org/ontology/knora-admin#KnownUser"
]
},
"object_iri": "http://rdfh.ch/0811/-lyPOifWRvqX-3o10X76gg"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"scope": {
"CR": [
"http://www.knora.org/ontology/knora-admin#Creator",
"http://www.knora.org/ontology/knora-admin#ProjectAdmin"
],
"D": [],
"M": [],
"V": [],
"RV": [
"http://www.knora.org/ontology/knora-admin#UnknownUser",
"http://www.knora.org/ontology/knora-admin#KnownUser"
]
},
"object_iri": "http://rdfh.ch/0811/-pTOksVbSdGThmfDKwWuDQ"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"scope": {
"CR": [
"http://www.knora.org/ontology/knora-admin#Creator",
"http://www.knora.org/ontology/knora-admin#ProjectAdmin"
],
"D": [],
"M": [],
"V": [],
"RV": [
"http://www.knora.org/ontology/knora-admin#UnknownUser",
"http://www.knora.org/ontology/knora-admin#KnownUser"
]
},
"object_iri": "http://rdfh.ch/0811/-spqnTVARweuZ4gaMMGQMQ"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"scope": {
"CR": [
"http://www.knora.org/ontology/knora-admin#Creator",
"http://www.knora.org/ontology/knora-admin#ProjectAdmin"
],
"D": [],
"M": [],
"V": [],
"RV": [
"http://www.knora.org/ontology/knora-admin#UnknownUser",
"http://www.knora.org/ontology/knora-admin#KnownUser"
]
},
"object_iri": "http://rdfh.ch/0811/-v1uy8seRx-dByUU7iwRdQ"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"scope": {
"CR": [
"http://www.knora.org/ontology/knora-admin#Creator",
"http://www.knora.org/ontology/knora-admin#ProjectAdmin"
],
"D": [],
"M": [],
"V": [],
"RV": [
"http://www.knora.org/ontology/knora-admin#UnknownUser",
"http://www.knora.org/ontology/knora-admin#KnownUser"
]
},
"object_iri": "http://rdfh.ch/0811/-zAGRXUkQEGyKgZ7Lk6i3Q"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"scope": {
"CR": [
"http://www.knora.org/ontology/knora-admin#Creator",
"http://www.knora.org/ontology/knora-admin#ProjectAdmin"
],
"D": [],
"M": [],
"V": [],
"RV": [
"http://www.knora.org/ontology/knora-admin#UnknownUser",
"http://www.knora.org/ontology/knora-admin#KnownUser"
]
},
"object_iri": "http://rdfh.ch/0811/0I2yOjHRQfKa0xVFfoXOdQ"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"scope": {
"CR": [
"http://www.knora.org/ontology/knora-admin#Creator",
"http://www.knora.org/ontology/knora-admin#ProjectAdmin"
],
"D": [],
"M": [],
"V": [],
"RV": [
"http://www.knora.org/ontology/knora-admin#UnknownUser",
"http://www.knora.org/ontology/knora-admin#KnownUser"
]
},
"object_iri": "http://rdfh.ch/0811/0R9FodgbSIWJgTPp7Wl7dg"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"scope": {
"CR": [
"http://www.knora.org/ontology/knora-admin#Creator",
"http://www.knora.org/ontology/knora-admin#ProjectAdmin"
],
"D": [],
"M": [],
"V": [],
"RV": [
"http://www.knora.org/ontology/knora-admin#UnknownUser",
"http://www.knora.org/ontology/knora-admin#KnownUser"
]
},
"object_iri": "http://rdfh.ch/0811/0V5cfxjpRK65a-mYiwaIMA"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"scope": {
"CR": [
"http://www.knora.org/ontology/knora-admin#Creator",
"http://www.knora.org/ontology/knora-admin#ProjectAdmin"
],
"D": [],
"M": [],
"V": [],
"RV": [
"http://www.knora.org/ontology/knora-admin#UnknownUser",
"http://www.knora.org/ontology/knora-admin#KnownUser"
]
},
"object_iri": "http://rdfh.ch/0811/0bFcGKHlQJqiEFcDR4252A"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"scope": {
"CR": [
"http://www.knora.org/ontology/knora-admin#Creator",
"http://www.knora.org/ontology/knora-admin#ProjectAdmin"
],
"D": [],
"M": [],
"V": [],
"RV": [
"http://www.knora.org/ontology/knora-admin#UnknownUser",
"http://www.knora.org/ontology/knora-admin#KnownUser"
]
},
"object_iri": "http://rdfh.ch/0811/0e7ObR9HTCyJkCxgOk31tA"
}
Loading
Loading