diff --git a/backend-plugin-sample/.annotation_safe_list.yml b/backend-plugin-sample/.annotation_safe_list.yml index 62eaaa7..deb98bf 100644 --- a/backend-plugin-sample/.annotation_safe_list.yml +++ b/backend-plugin-sample/.annotation_safe_list.yml @@ -39,3 +39,11 @@ waffle.Sample: ".. no_pii:": "This model has no PII" waffle.Switch: ".. no_pii:": "This model has no PII" +openedx_catalog.CatalogCourse: + ".. no_pii:": "This model has no PII" +openedx_catalog.CourseRun: + ".. no_pii:": "This model has no PII" +organizations.HistoricalOrganization: + ".. no_pii:": "This model has no PII" +organizations.HistoricalOrganizationCourse: + ".. no_pii:": "This model has no PII" diff --git a/backend-plugin-sample/pyproject.toml b/backend-plugin-sample/pyproject.toml index 9595618..7bd7a6b 100644 --- a/backend-plugin-sample/pyproject.toml +++ b/backend-plugin-sample/pyproject.toml @@ -32,6 +32,7 @@ dependencies = [ "djangorestframework", "django-filter", "edx-opaque-keys", + "openedx-core", "openedx-events", "openedx-filters", "openedx-atlas", diff --git a/backend-plugin-sample/src/openedx_plugin_sample/admin.py b/backend-plugin-sample/src/openedx_plugin_sample/admin.py new file mode 100644 index 0000000..ecf3fc7 --- /dev/null +++ b/backend-plugin-sample/src/openedx_plugin_sample/admin.py @@ -0,0 +1,55 @@ +""" +Django admin configuration for openedx_plugin_sample. + +This module demonstrates how to expose plugin models in the Django admin +site provided by Open edX (LMS and CMS each have their own admin under +``/admin/``). Defining a ``ModelAdmin`` for each model gives operators a +ready-made UI to inspect and manage plugin data without needing custom +tooling. + +Django Documentation: +- ModelAdmin: https://docs.djangoproject.com/en/stable/ref/contrib/admin/ +""" + +from django.contrib import admin + +from openedx_plugin_sample.models import CourseArchiveStatus + + +@admin.register(CourseArchiveStatus) +class CourseArchiveStatusAdmin(admin.ModelAdmin): + """ + Admin configuration for the CourseArchiveStatus model. + """ + + list_display = ( + "course_key", + "user", + "is_archived", + "archive_date", + "updated_at", + ) + list_filter = ("is_archived",) + # Search by the related CourseRun's course_key and the user's username/email. + search_fields = ( + "course_run__course_key", + "user__username", + "user__email", + ) + # FKs use raw id widgets (lookup popup) rather than a