From 5b9e84d32174f2b88e6593858e72bd6e9911bac5 Mon Sep 17 00:00:00 2001 From: Tinuade Adeleke Date: Wed, 8 Sep 2021 08:44:37 +0100 Subject: [PATCH] feat: created custom pages course app plugin (#28579) created CustomPagesCourseApp class feat: created custom pages course app plugin created CustomPagesCourseApp class added CUSTOM_PAGES_HELP_URL to lms and cms settings added entry point to setup.py feat: added toggle to ENABLE_CUSTOM_PAGES in lms and cms settings feat: removed the option to enable/disable the availability of custom pages course apps. --- cms/envs/common.py | 1 + lms/djangoapps/courseware/plugins.py | 52 ++++++++++++++++++++++++++++ lms/envs/common.py | 1 + setup.py | 1 + 4 files changed, 55 insertions(+) diff --git a/cms/envs/common.py b/cms/envs/common.py index c059ee68be..5af3d7ab9b 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -2494,3 +2494,4 @@ PROGRESS_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-r TEAMS_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/course_features/teams/teams_setup.html" TEXTBOOKS_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/course_assets/textbooks.html" WIKI_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/course_assets/course_wiki.html" +CUSTOM_PAGES_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/course_assets/pages.html#adding-custom-pages" diff --git a/lms/djangoapps/courseware/plugins.py b/lms/djangoapps/courseware/plugins.py index 55f3e5874b..18b23f5c2a 100644 --- a/lms/djangoapps/courseware/plugins.py +++ b/lms/djangoapps/courseware/plugins.py @@ -212,3 +212,55 @@ class ProctoringCourseApp(CourseApp): @staticmethod def legacy_link(course_key: CourseKey): return get_proctored_exam_settings_url(course_key) + + +class CustomPagesCourseApp(CourseApp): + """ + Course app config for custom pages app. + """ + + app_id = "custom_pages" + name = _("Custom pages") + description = _("Provide additional course content and resources with custom pages") + documentation_links = { + "learn_more_configuration": settings.CUSTOM_PAGES_HELP_URL, + } + + @classmethod + def is_available(cls, course_key: CourseKey) -> bool: # pylint: disable=unused-argument + """ + The custom pages app is available for all courses. + """ + return True + + @classmethod + def is_enabled(cls, course_key: CourseKey) -> bool: # pylint: disable=unused-argument + """ + Returns if the custom pages app is enabled. + For now this feature is enabled without any manual setup + """ + return True + + @classmethod + def set_enabled(cls, course_key: CourseKey, enabled: bool, user: 'User') -> bool: + """ + The custom pages app can be globally enabled/disabled. + + Currently, it isn't possible to enable/disable this app on a per-course basis. + """ + raise ValueError("The custom pages app can not be enabled/disabled for a single course.") + + @classmethod + def get_allowed_operations(cls, course_key: CourseKey, user: Optional[User] = None) -> Dict[str, bool]: + """ + Returns the allowed operations for the app. + """ + return { + # Either the app is available and configurable or not. You cannot disable it from the API yet. + "enable": False, + "configure": True, + } + + @staticmethod + def legacy_link(course_key: CourseKey): + return urls.reverse('tabs_handler', kwargs={'course_key_string': course_key}) diff --git a/lms/envs/common.py b/lms/envs/common.py index cc42b2131e..4862bc59ee 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -4813,3 +4813,4 @@ PROGRESS_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-r TEAMS_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/course_features/teams/teams_setup.html" TEXTBOOKS_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/course_assets/textbooks.html" WIKI_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/course_assets/course_wiki.html" +CUSTOM_PAGES_HELP_URL = "https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/course_assets/pages.html#adding-custom-pages" diff --git a/setup.py b/setup.py index d521bb2947..583273d1f0 100644 --- a/setup.py +++ b/setup.py @@ -47,6 +47,7 @@ setup( "teams = lms.djangoapps.teams.plugins:TeamsCourseApp", "textbooks = lms.djangoapps.courseware.plugins:TextbooksCourseApp", "wiki = lms.djangoapps.course_wiki.plugins:WikiCourseApp", + "custom_pages = lms.djangoapps.courseware.plugins:CustomPagesCourseApp", ], "openedx.course_tool": [ "calendar_sync_toggle = openedx.features.calendar_sync.plugins:CalendarSyncToggleTool",