From da9adf8aa379d0387c1da1c54b9423d41bbe86f7 Mon Sep 17 00:00:00 2001 From: Jillian Date: Thu, 26 Sep 2024 10:02:41 +0930 Subject: [PATCH] Warn Django Admin users editing Collections [FC-0036] (#233) * docs: wrap collections edit page in a warning so users know to use Studio Django Admin instead of the LMS. * docs: improve "enabled" flag help docs * chore: bumps version to 0.13.1 --- openedx_learning/__init__.py | 2 +- .../apps/authoring/collections/admin.py | 17 ++++++++++++++++- ...lection_options_alter_collection_enabled.py | 18 ++++++++++++++++++ .../apps/authoring/collections/models.py | 4 +--- 4 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 openedx_learning/apps/authoring/collections/migrations/0005_alter_collection_options_alter_collection_enabled.py diff --git a/openedx_learning/__init__.py b/openedx_learning/__init__.py index 31d6d241..5bf29b11 100644 --- a/openedx_learning/__init__.py +++ b/openedx_learning/__init__.py @@ -1,4 +1,4 @@ """ Open edX Learning ("Learning Core"). """ -__version__ = "0.13.0" +__version__ = "0.13.1" diff --git a/openedx_learning/apps/authoring/collections/admin.py b/openedx_learning/apps/authoring/collections/admin.py index 0d49732c..eb0685a2 100644 --- a/openedx_learning/apps/authoring/collections/admin.py +++ b/openedx_learning/apps/authoring/collections/admin.py @@ -2,6 +2,7 @@ Django Admin pages for Collection models. """ from django.contrib import admin +from django.utils.translation import gettext_lazy as _ from .models import Collection @@ -15,7 +16,21 @@ class CollectionAdmin(admin.ModelAdmin): readonly_fields = ["key", "learning_package"] list_filter = ["enabled"] list_display = ["key", "title", "enabled", "modified"] - list_editable = ["enabled"] + fieldsets = [ + ( + "", + { + "fields": ["key", "learning_package"], + } + ), + ( + _("Edit only in Studio"), + { + "fields": ["title", "enabled", "description", "created_by"], + "description": _("⚠ Changes made here should be done in Studio Django Admin, not the LMS."), + } + ), + ] def has_add_permission(self, request, *args, **kwargs): """ diff --git a/openedx_learning/apps/authoring/collections/migrations/0005_alter_collection_options_alter_collection_enabled.py b/openedx_learning/apps/authoring/collections/migrations/0005_alter_collection_options_alter_collection_enabled.py new file mode 100644 index 00000000..17405dac --- /dev/null +++ b/openedx_learning/apps/authoring/collections/migrations/0005_alter_collection_options_alter_collection_enabled.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.15 on 2024-09-24 07:31 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('oel_collections', '0004_collection_key'), + ] + + operations = [ + migrations.AlterField( + model_name='collection', + name='enabled', + field=models.BooleanField(default=True, help_text='Disabled collections are "soft deleted", and should be re-enabled before use, or be deleted.'), + ), + ] diff --git a/openedx_learning/apps/authoring/collections/models.py b/openedx_learning/apps/authoring/collections/models.py index 24adce69..731f2cb7 100644 --- a/openedx_learning/apps/authoring/collections/models.py +++ b/openedx_learning/apps/authoring/collections/models.py @@ -133,12 +133,10 @@ class Collection(models.Model): } ) - # We don't have api functions to handle the enabled field. This is a placeholder for future use and - # a way to "soft delete" collections. enabled = models.BooleanField( default=True, help_text=_( - "Whether the collection is enabled or not." + 'Disabled collections are "soft deleted", and should be re-enabled before use, or be deleted.', ), )