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