feat: Supply documentation links for course apps from the backend (#28327)

Instead of hard-coding the "Learn More" and potentially other links for course
apps in the course authoring  MFEs this change loads those URLs from the
django settings as part of each individual course app.
This commit is contained in:
Kshitij Sobti
2021-08-04 15:34:13 +05:30
committed by GitHub
parent 8e4e9a1d39
commit 6cbb9cbca3
9 changed files with 51 additions and 0 deletions

View File

@@ -23,6 +23,11 @@ class CourseApp(ABC):
name: str = ""
# A description for the app.
description: str = ""
# A map of documentation links for the app
documentation_links: Dict = {
# eg:
# "learn_more_configuration": "https://..."
}
@classmethod
@abstractmethod

View File

@@ -51,6 +51,7 @@ class CourseAppSerializer(serializers.Serializer): # pylint: disable=abstract-m
name = serializers.CharField(read_only=True, help_text="Friendly name of the course app.")
description = serializers.CharField(read_only=True, help_text="A friendly description of what the course app does.")
legacy_link = serializers.URLField(required=False, help_text="A link to the course app in the legacy studio view.")
documentation_links = serializers.JSONField(required=True)
allowed_operations = serializers.DictField(
read_only=True,
help_text="What all operations are supported by the app.",
@@ -65,6 +66,7 @@ class CourseAppSerializer(serializers.Serializer): # pylint: disable=abstract-m
"name": instance.name,
"description": instance.description,
"allowed_operations": instance.get_allowed_operations(course_key, request.user),
"documentation_links": instance.documentation_links,
}
if hasattr(instance, "legacy_link"):
data["legacy_link"] = request.build_absolute_uri(instance.legacy_link(course_key))

View File

@@ -3,6 +3,7 @@ Course app configuration for discussions.
"""
from typing import Dict, Optional
from django.conf import settings
from django.contrib.auth import get_user_model
from django.utils.translation import ugettext_noop as _
from opaque_keys.edx.keys import CourseKey
@@ -21,6 +22,9 @@ class DiscussionCourseApp(CourseApp):
app_id = "discussion"
name = _("Discussion")
description = _("Encourage participation and engagement in your course with discussions.")
documentation_links = {
"learn_more_configuration": settings.DISCUSSIONS_HELP_URL,
}
@classmethod
def is_available(cls, course_key: CourseKey) -> bool: