Skip to content

feat: bulk add courses to base catalog - #67

Open
ccantillo wants to merge 4 commits into
mainfrom
crls/feat/bulk-add-courses-to-base-catalog
Open

feat: bulk add courses to base catalog#67
ccantillo wants to merge 4 commits into
mainfrom
crls/feat/bulk-add-courses-to-base-catalog

Conversation

@ccantillo

Copy link
Copy Markdown
Contributor

Bulk add courses to Base Catalog

Summary

Administrators could only add one course at a time to the Base Catalog, which
was impractical when dealing with dozens or hundreds of courses. This PR adds a
Bulk Add Courses page to the BaseCatalog admin interface, featuring a
visual dual-panel course picker with search, select, and batch-add capabilities.


What changed

partner_catalog/admin.py

  • Added BulkAddCoursesForm — a Django form using the FilteredSelectMultiple
    widget, which renders the built-in Django admin dual-panel picker.
  • Added get_urls() to BaseCatalogAdmin to register a custom admin route:
    /<uuid>/bulk-add-courses/
  • Added bulk_add_courses_view() — handles GET (render picker) and POST (save
    selected courses). Courses are added via BaseCatalogCourse.get_or_create,
    so duplicate submissions are safe.
  • Updated add_course_button (detail page) to show two buttons:
    + Add Single Course (existing flow) and + Bulk Add Courses (new).
  • Updated add_course (list view column) to link directly to the bulk-add page.

partner_catalog/templates/admin/partner_catalog/basecatalog/bulk_add_courses.html

New admin template extending admin/base_site.html with proper CSS
(admin/css/forms.css) and JS (jsi18n + combined admin+form media) loading.


How the picker works

The Available Courses panel (left) lists all courses not yet in the
catalog, sorted alphabetically. The Chosen Courses panel (right) holds the
courses selected for addition.

Action How
Select a single course Click it in the left panel
Select multiple courses Ctrl + click (or Cmd + click on Mac) each course
Move selected to right Click the Choose selected Courses arrow button
Move all visible to right Click Choose all Courses
Deselect / remove Select in right panel → Remove selected Courses
Remove all chosen Click Remove all Courses
Filter courses by name Type in the Filter box above either panel — results update instantly

Important: the Choose all Courses button adds only the courses
currently visible after filtering. Type a search term first and then
click "Choose all" to bulk-select only the matching results.

Once the desired courses are in the right panel, click Add Selected Courses
to save. The admin redirects back to the BaseCatalog detail page and shows a
success message with the count of courses added.


Files changed

Repo File Change
openedx-corporate partner_catalog/admin.py BulkAddCoursesForm, get_urls, bulk_add_courses_view, updated buttons
openedx-corporate partner_catalog/templates/admin/partner_catalog/basecatalog/bulk_add_courses.html New template for the bulk-add page

Testing

  1. Go to /admin/partner_catalog/basecatalog/.
  2. Click + Bulk Add Courses in the list view, or open a catalog and click
    the green + Bulk Add Courses button.
  3. The picker opens showing all courses not yet in the catalog.
  4. Use the Filter box, Ctrl + click to multi-select, and the arrow buttons to
    move courses to the right panel.
  5. Click Add Selected Courses — redirects back to the catalog detail page
    with a success message confirming how many courses were added.
  6. Confirm the Total Courses count on the detail page has increased.
  7. Re-open the bulk-add page and confirm the newly added courses no longer
    appear in the Available Courses panel.

@ccantillo
ccantillo requested a review from rguerra-fccn July 9, 2026 18:03
@ccantillo
ccantillo marked this pull request as ready for review July 9, 2026 18:36
@igobranco
igobranco requested review from a team and igobranco July 10, 2026 10:15
@igobranco

igobranco commented Jul 10, 2026

Copy link
Copy Markdown
Member

@ccantillo in future please add screenshots!

I have tested locally and it seems to be working fine.

Nevertheless, this is not good enough! The functionality requested needs to be improved. We can't just "Add Bulk Courses" but also we need to improve it so it is a "Manage Bulk Courses".
The both select multiples need to work has User Groups on Django. Like the use case: /admin/auth/group/1/change/

Screenshots of the corporate module:

image image image

Screenshot of Manage User Group:

image

On refresh it still loads the existing groups.

@igobranco igobranco left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transform it to be like Manage Bulk Courses.
Currently I didn't find a way to remove courses.

@ccantillo

Copy link
Copy Markdown
Contributor Author

Transform it to be like Manage Bulk Courses. Currently I didn't find a way to remove courses.

Hi @igobranco, thanks for the feedback!

Reworked the implementation to match the auth/group pattern. The "Bulk Add Courses" separate page is gone — the FilteredSelectMultiple widget now lives directly on the BaseCatalog change form, pre-populated with the catalog's current courses on load.

A single Save now handles both additions and removals: it diffs the selected set against the current BaseCatalogCourse entries, creates the new ones (preserving added_by/added_at metadata), and deletes the removed ones.

image image

@igobranco
igobranco self-requested a review July 13, 2026 09:00

@igobranco igobranco left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✔️

Image Image

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