Skip to content

Commit 7ad8f6a

Browse files
committed
feat: add ContentLibraryData and enhance PermissionData with identifier property
1 parent 5c080f4 commit 7ad8f6a

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

openedx_authz/api/data.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"RoleData",
1818
"ScopeData",
1919
"SubjectData",
20+
"ContentLibraryData",
2021
]
2122

2223
AUTHZ_POLICY_ATTRIBUTES_SEPARATOR = "^"
@@ -556,6 +557,15 @@ class PermissionData:
556557
action: ActionData = None
557558
effect: Literal["allow", "deny"] = "allow"
558559

560+
@property
561+
def identifier(self) -> str:
562+
"""Get the permission identifier.
563+
564+
Returns:
565+
str: The permission identifier (e.g., 'delete_library').
566+
"""
567+
return self.action.external_key
568+
559569
def __str__(self):
560570
"""Human readable string representation of the permission and its effect."""
561571
return f"{self.action} - {self.effect}"
@@ -606,6 +616,14 @@ def name(self) -> str:
606616
"""
607617
return self.external_key.replace("_", " ").title()
608618

619+
def get_permission_identifiers(self) -> list[str]:
620+
"""Get the technical identifiers for all permissions in this role.
621+
622+
Returns:
623+
list[str]: Permission identifiers (e.g., ['delete_library', 'edit_content']).
624+
"""
625+
return [permission.identifier for permission in self.permissions]
626+
609627
def __str__(self):
610628
"""Human readable string representation of the role and its permissions."""
611629
return f"{self.name}: {', '.join(str(p) for p in self.permissions)}"

0 commit comments

Comments
 (0)