|
14 | 14 | from opaque_keys.edx.locator import LibraryLocatorV2 |
15 | 15 | from organizations.models import Organization |
16 | 16 |
|
17 | | -from openedx_authz.constants.permissions import COURSES_VIEW_COURSE_TEAM, VIEW_LIBRARY_TEAM |
| 17 | +from openedx_authz.constants.permissions import ( |
| 18 | + COURSES_MANAGE_COURSE_TEAM, |
| 19 | + COURSES_VIEW_COURSE_TEAM, |
| 20 | + MANAGE_LIBRARY_TEAM, |
| 21 | + VIEW_LIBRARY_TEAM, |
| 22 | +) |
18 | 23 | from openedx_authz.data import AUTHZ_POLICY_ATTRIBUTES_SEPARATOR, ActionData, AuthzBaseClass, AuthZData, PermissionData |
19 | 24 | from openedx_authz.models.scopes import get_content_library_model, get_course_overview_model |
20 | 25 |
|
@@ -357,6 +362,20 @@ def get_admin_view_permission(cls) -> PermissionData: |
357 | 362 | """ |
358 | 363 | raise NotImplementedError("Subclasses must implement get_admin_view_permission method.") |
359 | 364 |
|
| 365 | + @classmethod |
| 366 | + @abstractmethod |
| 367 | + def get_admin_manage_permission(cls) -> PermissionData: |
| 368 | + """Get the permission required to manage this scope |
| 369 | +
|
| 370 | + This method should be implemented on every ScopeData subclass to define |
| 371 | + which permission to check against when a user tries to manage assignations |
| 372 | + related to this scope in the Admin Console. |
| 373 | +
|
| 374 | + Returns: |
| 375 | + PermissionData: The permission required to manage this scope in the admin console. |
| 376 | + """ |
| 377 | + raise NotImplementedError("Subclasses must implement get_admin_manage_permission method.") |
| 378 | + |
360 | 379 | @abstractmethod |
361 | 380 | def get_object(self) -> Any | None: |
362 | 381 | """Retrieve the underlying domain object that this scope represents. |
@@ -463,6 +482,15 @@ def get_admin_view_permission(cls) -> PermissionData: |
463 | 482 | """ |
464 | 483 | return VIEW_LIBRARY_TEAM |
465 | 484 |
|
| 485 | + @classmethod |
| 486 | + def get_admin_manage_permission(cls) -> PermissionData: |
| 487 | + """Get the permission required to manage this scope |
| 488 | +
|
| 489 | + Returns: |
| 490 | + PermissionData: The permission required to manage this scope in the admin console. |
| 491 | + """ |
| 492 | + return MANAGE_LIBRARY_TEAM |
| 493 | + |
466 | 494 | def get_object(self) -> ContentLibrary | None: |
467 | 495 | """Retrieve the ContentLibrary instance associated with this scope. |
468 | 496 |
|
@@ -585,6 +613,15 @@ def get_admin_view_permission(cls) -> PermissionData: |
585 | 613 | """ |
586 | 614 | return COURSES_VIEW_COURSE_TEAM |
587 | 615 |
|
| 616 | + @classmethod |
| 617 | + def get_admin_manage_permission(cls) -> PermissionData: |
| 618 | + """Get the permission required to manage this scope |
| 619 | +
|
| 620 | + Returns: |
| 621 | + PermissionData: The permission required to manage this scope in the admin console. |
| 622 | + """ |
| 623 | + return COURSES_MANAGE_COURSE_TEAM |
| 624 | + |
588 | 625 | def get_object(self) -> CourseOverview | None: |
589 | 626 | """Retrieve the CourseOverview instance associated with this scope. |
590 | 627 |
|
@@ -715,6 +752,15 @@ def build_external_key(cls, org: str) -> str: |
715 | 752 | """ |
716 | 753 | return f"{cls.NAMESPACE}{EXTERNAL_KEY_SEPARATOR}{org}{cls.ID_SEPARATOR}{GLOBAL_SCOPE_WILDCARD}" |
717 | 754 |
|
| 755 | + @classmethod |
| 756 | + def get_admin_manage_permission(cls) -> PermissionData: |
| 757 | + """Get the permission required to manage this scope |
| 758 | +
|
| 759 | + Returns: |
| 760 | + PermissionData: The permission required to manage this scope in the admin console. |
| 761 | + """ |
| 762 | + raise NotImplementedError("Subclasses must implement get_admin_manage_permission method.") |
| 763 | + |
718 | 764 | @classmethod |
719 | 765 | def get_org(cls, external_key: str) -> str | None: |
720 | 766 | """Extract the organization identifier from the glob pattern. |
@@ -813,6 +859,15 @@ def get_admin_view_permission(cls) -> PermissionData: |
813 | 859 | """ |
814 | 860 | return VIEW_LIBRARY_TEAM |
815 | 861 |
|
| 862 | + @classmethod |
| 863 | + def get_admin_manage_permission(cls) -> PermissionData: |
| 864 | + """Get the permission required to manage this scope |
| 865 | +
|
| 866 | + Returns: |
| 867 | + PermissionData: The permission required to manage this scope in the admin console. |
| 868 | + """ |
| 869 | + return MANAGE_LIBRARY_TEAM |
| 870 | + |
816 | 871 |
|
817 | 872 | @define |
818 | 873 | class OrgCourseOverviewGlobData(OrgGlobData): |
@@ -862,6 +917,15 @@ def get_admin_view_permission(cls) -> PermissionData: |
862 | 917 | """ |
863 | 918 | return COURSES_VIEW_COURSE_TEAM |
864 | 919 |
|
| 920 | + @classmethod |
| 921 | + def get_admin_manage_permission(cls) -> PermissionData: |
| 922 | + """Get the permission required to manage this scope |
| 923 | +
|
| 924 | + Returns: |
| 925 | + PermissionData: The permission required to manage this scope in the admin console. |
| 926 | + """ |
| 927 | + return COURSES_MANAGE_COURSE_TEAM |
| 928 | + |
865 | 929 |
|
866 | 930 | class CCXCourseOverviewData(CourseOverviewData): |
867 | 931 | """CCX course scope for authorization in the Open edX platform. |
|
0 commit comments