Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum committed Aug 12, 2024
1 parent fa648e8 commit 035163b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
8 changes: 6 additions & 2 deletions dsp_permissions_scripts/models/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from pydantic import model_validator

from dsp_permissions_scripts.models.errors import InvalidGroupError
from dsp_permissions_scripts.utils.helpers import KNORA_ADMIN_ONTO_NAMESPACE

KNORA_ADMIN_ONTO_NAMESPACE = "http://www.knora.org/ontology/knora-admin#"


class Group(BaseModel):
Expand All @@ -16,7 +17,10 @@ class Group(BaseModel):
val: str

@model_validator(mode="before")
def _shorten_iri(self, data: dict[str, Any]) -> dict[str, Any]:
@classmethod
def _shorten_iri(cls, data: Any) -> Any:
if not isinstance(data, dict):
return data
data["val"] = data["val"].replace(KNORA_ADMIN_ONTO_NAMESPACE, "knora-admin:")
return data

Expand Down
2 changes: 1 addition & 1 deletion dsp_permissions_scripts/oap/oap_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

from dsp_permissions_scripts.models.errors import ApiError
from dsp_permissions_scripts.models.errors import PermissionsAlreadyUpToDate
from dsp_permissions_scripts.models.group import KNORA_ADMIN_ONTO_NAMESPACE
from dsp_permissions_scripts.models.scope import PermissionScope
from dsp_permissions_scripts.oap.oap_model import ResourceOap
from dsp_permissions_scripts.oap.oap_model import ValueOap
from dsp_permissions_scripts.utils.dsp_client import DspClient
from dsp_permissions_scripts.utils.get_logger import get_logger
from dsp_permissions_scripts.utils.helpers import KNORA_ADMIN_ONTO_NAMESPACE
from dsp_permissions_scripts.utils.scope_serialization import create_string_from_scope

logger = get_logger(__name__)
Expand Down
1 change: 0 additions & 1 deletion dsp_permissions_scripts/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from dsp_permissions_scripts.models import group

PACKAGE_NAME = "dsp-permissions-scripts"
KNORA_ADMIN_ONTO_NAMESPACE = "http://www.knora.org/ontology/knora-admin#"


def dereference_prefix(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_scope_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from pytest_unordered import unordered

from dsp_permissions_scripts.models import group
from dsp_permissions_scripts.models.group import KNORA_ADMIN_ONTO_NAMESPACE
from dsp_permissions_scripts.models.scope import PermissionScope
from dsp_permissions_scripts.utils.helpers import KNORA_ADMIN_ONTO_NAMESPACE
from dsp_permissions_scripts.utils.scope_serialization import create_admin_route_object_from_scope
from dsp_permissions_scripts.utils.scope_serialization import create_scope_from_admin_route_object
from dsp_permissions_scripts.utils.scope_serialization import create_scope_from_string
Expand Down

0 comments on commit 035163b

Please sign in to comment.