feat: Add helper for discussions configuration to indicate feature support
This commit is contained in:
@@ -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:
|
||||
"""
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user