diff --git a/openedx/core/djangoapps/discussions/models.py b/openedx/core/djangoapps/discussions/models.py index 770246e637..21df38995c 100644 --- a/openedx/core/djangoapps/discussions/models.py +++ b/openedx/core/djangoapps/discussions/models.py @@ -23,6 +23,17 @@ log = logging.getLogger(__name__) DEFAULT_PROVIDER_TYPE = 'legacy' +PROVIDER_FEATURE_MAP = { + 'legacy': [ + 'discussion-page', + 'embedded-course-sections', + 'wcag-2.1', + ], + 'piazza': [ + 'discussion-page', + 'lti', + ], +} def get_supported_providers() -> list[str]: @@ -179,6 +190,14 @@ class DiscussionsConfiguration(TimeStampedModel): enabled=self.enabled, ) + def supports(self, feature: str) -> bool: + """ + Check if the provider supports some feature + """ + features = PROVIDER_FEATURE_MAP.get(self.provider_type) or [] + has_support = bool(feature in features) + return has_support + @classmethod def is_enabled(cls, context_key: CourseKey) -> bool: """ diff --git a/openedx/core/djangoapps/discussions/views.py b/openedx/core/djangoapps/discussions/views.py index 6711b086fb..1a46104923 100644 --- a/openedx/core/djangoapps/discussions/views.py +++ b/openedx/core/djangoapps/discussions/views.py @@ -16,19 +16,7 @@ from openedx.core.lib.api.authentication import BearerAuthenticationAllowInactiv from .models import DEFAULT_PROVIDER_TYPE from .models import DiscussionsConfiguration - - -PROVIDER_FEATURE_MAP = { - 'legacy': [ - 'discussion-page', - 'embedded-course-sections', - 'wcag-2.1', - ], - 'piazza': [ - 'discussion-page', - 'lti', - ], -} +from .models import PROVIDER_FEATURE_MAP class IsStaff(BasePermission):