Skip to content

Use CourseRun Model & Add Admin Page#42

Merged
kdmccormick merged 2 commits into
mainfrom
kdmccormick/course-run-model
May 14, 2026
Merged

Use CourseRun Model & Add Admin Page#42
kdmccormick merged 2 commits into
mainfrom
kdmccormick/course-run-model

Conversation

@kdmccormick
Copy link
Copy Markdown
Member

@kdmccormick kdmccormick commented May 14, 2026

Description

Add openedx-core as a dep and use its openedx_catalog CourseRun model, which demonstrates our new stable core APIs a bit.

Also, adds an admin page, which shows the FK relationship, and is also just a great practice for plugins to follow.

Testing

I tested that the feature still works as it did before. Here's the admin page:

Screenshot 2026-05-13 at 9 58 54 PM

Note that I had to un-migrate and re-migrate, since the models are rewritten in-place rather than smoothly migrated with a 0002:

tutor dev run lms ./manage.py lms migrate openedx_plugin_sample zero
tutor dev run lms ./manage.py lms migrate openedx_plugin_sample

AI

Claude wrote it, I reviewed it, and I had it simplify the implementation a bit before committing. Main prompts:

within backend-plugin-sample/.venv, i've installed openedx-core, whose openedx_catalog djangoapp include a CourseRun django model. rather than having a CourseKeyField on CourseArchiveStatus, I'd like a foreign key to CourseRu. check out the docstrings in openedx_catalog; they will help.

oh, i forgot mention: no need to migrate the data smoothly. clobber the existing 0001 migration for openedx_plugin_sample and re-generate with ./manage.py makemigrations

awesome. next up, could you make a standard django admin page for our sample plugin and its one model?

@kdmccormick kdmccormick requested a review from feanil May 14, 2026 02:00
@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.04%. Comparing base (1291e3e) to head (176be8c).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #42      +/-   ##
==========================================
+ Coverage   92.60%   93.04%   +0.44%     
==========================================
  Files          16       16              
  Lines         473      503      +30     
  Branches       18       18              
==========================================
+ Hits          438      468      +30     
  Misses         24       24              
  Partials       11       11              
Flag Coverage Δ
unittests 93.04% <ø> (+0.44%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kdmccormick kdmccormick force-pushed the kdmccormick/course-run-model branch from 9efde31 to d26c53a Compare May 14, 2026 02:08
kdmccormick and others added 2 commits May 14, 2026 11:58
Replace the CourseKeyField on CourseArchiveStatus with a ForeignKey to
openedx_catalog.CourseRun, following the new "use a FK to CourseRun for
any model-level course reference" guidance from openedx-core. The public
API still identifies courses by their course_key string (never by
CourseRun's internal PK), so frontend consumers and the JSON contract
are unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Expose the sample plugin's one model in the LMS/CMS admin so operators
can inspect and manage records without custom tooling, and so the
sample demonstrates the standard ModelAdmin pattern alongside the
other plugin interfaces.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kdmccormick kdmccormick force-pushed the kdmccormick/course-run-model branch 2 times, most recently from d26c53a to 176be8c Compare May 14, 2026 15:58
@kdmccormick kdmccormick enabled auto-merge (rebase) May 14, 2026 15:59
@kdmccormick kdmccormick merged commit f889918 into main May 14, 2026
7 checks passed
@kdmccormick kdmccormick deleted the kdmccormick/course-run-model branch May 14, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants