From b5fd4cc55f16950e8903f41e3ac0e20d99810fd8 Mon Sep 17 00:00:00 2001 From: Kyle McCormick Date: Tue, 7 Feb 2023 08:17:01 -0500 Subject: [PATCH] fix: allow content libraries to be created through Django admin (#31719) Previously, CMS Django admin would demand that at least one LTIConfig be associated with the new library. This is not necessary, but Django thought it was, because the `blank` flag was not enabled on the ContentLibrary model's `authored_lti_config` many-to-many field. This should not affect the experimental blockstore-based library authoring frontend, which already allows libraries to be created without any authorized_lti_configs. This will not affect the existing modulestore-based library authoring frontend, since it doesn't even use any of the models in question. A migration is included with this commit, but it should NOT change MySQL schema, since `blank` is a Django-level validation flag. --- ...r_contentlibrary_authorized_lti_configs.py | 19 +++++++++++++++++++ .../djangoapps/content_libraries/models.py | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 openedx/core/djangoapps/content_libraries/migrations/0009_alter_contentlibrary_authorized_lti_configs.py diff --git a/openedx/core/djangoapps/content_libraries/migrations/0009_alter_contentlibrary_authorized_lti_configs.py b/openedx/core/djangoapps/content_libraries/migrations/0009_alter_contentlibrary_authorized_lti_configs.py new file mode 100644 index 0000000000..dd4bf12fe9 --- /dev/null +++ b/openedx/core/djangoapps/content_libraries/migrations/0009_alter_contentlibrary_authorized_lti_configs.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.16 on 2023-02-06 21:39 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('lti1p3_tool_config', '0001_initial'), + ('content_libraries', '0008_auto_20210818_2148'), + ] + + operations = [ + migrations.AlterField( + model_name='contentlibrary', + name='authorized_lti_configs', + field=models.ManyToManyField(blank=True, help_text="List of authorized LTI tool configurations that can access this library's content through LTI launches, if empty no LTI launch is allowed.", related_name='content_libraries', to='lti1p3_tool_config.LtiTool'), + ), + ] diff --git a/openedx/core/djangoapps/content_libraries/models.py b/openedx/core/djangoapps/content_libraries/models.py index 32e2103e0d..7bf8792699 100644 --- a/openedx/core/djangoapps/content_libraries/models.py +++ b/openedx/core/djangoapps/content_libraries/models.py @@ -126,7 +126,8 @@ class ContentLibrary(models.Model): related_name='content_libraries', help_text=("List of authorized LTI tool configurations that can access " "this library's content through LTI launches, if empty no LTI " - "launch is allowed.") + "launch is allowed."), + blank=True, ) class Meta: