Skip to content
Snippets Groups Projects
Unverified Commit 8c6a06cf authored by David Joy's avatar David Joy Committed by GitHub
Browse files

fix: adjust discussions app APIs to match consuming frontend (#27085)

This commit adjusts a few values in our discussions configuration APIs to make them match what the frontend needs, as well as to more accurately reflect the providers available today.

- The `active` provider ID is expressed as None if it doesn’t exist
- The “cs_comments_service” provider has been renamed “legacy” - when we implement the new discussions micro-frontend, we’ll also have a separate provider for that, so they can’t both be “cs_comments_service”.  Also, cs_comments_service is such a bad name for anything.
- The hard-coded providers list in get_supported_providers now includes ‘legacy’ and ‘piazza’, our two known providers.  This list will be updated as more known providers come online.
- The PROVIDER_FEATURE_MAP has similarly been updated.

Part of this task: TNL-8093
parent a0003016
No related branches found
Tags release-2021-03-23-15.07
No related merge requests found
# Generated by Django 2.2.19 on 2021-03-23 14:46
from django.db import migrations, models
import django_mysql.models
class Migration(migrations.Migration):
dependencies = [
('discussions', '0002_add_provider_filter'),
]
operations = [
migrations.AlterField(
model_name='providerfilter',
name='allow',
field=django_mysql.models.ListCharField(models.CharField(choices=[('legacy', 'legacy'), ('piazza', 'piazza')], max_length=20), blank=True, help_text='Comma-separated list of providers to allow, eg: legacy,piazza', max_length=63, size=3, verbose_name='Allow List'),
),
migrations.AlterField(
model_name='providerfilter',
name='deny',
field=django_mysql.models.ListCharField(models.CharField(choices=[('legacy', 'legacy'), ('piazza', 'piazza')], max_length=20), blank=True, help_text='Comma-separated list of providers to deny, eg: legacy,piazza', max_length=63, size=3, verbose_name='Deny List'),
),
]
......@@ -29,9 +29,8 @@ def get_supported_providers() -> list[str]:
TODO: Load this from entry points?
"""
providers = [
'cs_comments_service',
'lti',
'test',
'legacy',
'piazza',
]
return providers
......
......@@ -13,9 +13,8 @@ from ..models import DiscussionsConfiguration
from ..models import ProviderFilter
SUPPORTED_PROVIDERS = [
'cs_comments_service',
'lti',
'test',
'legacy',
'piazza',
]
......@@ -137,7 +136,7 @@ class DiscussionsConfigurationModelTest(TestCase):
self.configuration_with_values = DiscussionsConfiguration(
context_key=self.course_key_with_values,
enabled=False,
provider_type='cs_comments_service',
provider_type='legacy',
plugin_configuration={
'url': 'http://localhost',
},
......@@ -186,14 +185,14 @@ class DiscussionsConfigurationModelTest(TestCase):
configuration.plugin_configuration = {
'url': 'http://localhost',
}
configuration.provider_type = 'cs_comments_service'
configuration.provider_type = 'legacy'
configuration.save()
configuration = DiscussionsConfiguration.objects.get(context_key=self.course_key_with_defaults)
assert configuration is not None
assert not configuration.enabled
assert configuration.lti_configuration is None
assert configuration.plugin_configuration['url'] == 'http://localhost'
assert configuration.provider_type == 'cs_comments_service'
assert configuration.provider_type == 'legacy'
def test_is_enabled_nonexistent(self):
"""
......@@ -247,4 +246,4 @@ class DiscussionsConfigurationModelTest(TestCase):
assert not configuration.enabled
assert not configuration.lti_configuration
assert configuration.plugin_configuration
assert configuration.provider_type == 'cs_comments_service'
assert configuration.provider_type == 'legacy'
......@@ -14,10 +14,9 @@ from .models import DiscussionsConfiguration
PROVIDER_FEATURE_MAP = {
'cs_comments_service': [
'legacy': [
'discussion-page',
'embedded-course-sections',
'lti',
'wcag-2.1',
],
'piazza': [
......@@ -66,7 +65,7 @@ class DiscussionsConfigurationView(APIView):
},
'plugin_configuration': instance.plugin_configuration,
'providers': {
'active': instance.provider_type or '',
'active': instance.provider_type or None,
'available': {
provider: {
'features': PROVIDER_FEATURE_MAP.get(provider) or [],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment