feat: Add helper for discussions configuration to indicate feature support

This commit is contained in:
stvn
2021-04-17 00:41:32 -07:00
parent fb2f8e6291
commit c1742b7b66
2 changed files with 20 additions and 13 deletions

View File

@@ -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:
"""

View File

@@ -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):