Skip to content

Crls/feat/show manager username and counts in catalog admin - #64

Open
ccantillo wants to merge 6 commits into
mainfrom
crls/feat/show-manager-username-and-counts-in-catalog-admin
Open

Crls/feat/show manager username and counts in catalog admin#64
ccantillo wants to merge 6 commits into
mainfrom
crls/feat/show-manager-username-and-counts-in-catalog-admin

Conversation

@ccantillo

Copy link
Copy Markdown
Contributor

Show counts and manager usernames in PartnerCatalog admin list

Summary

Improves the PartnerCatalog change list in Django admin so that admins
can see at a glance how many learners and courses each catalog has, and
who is managing it — without leaving the list view.


What changed

Column behaviour

The Add Learner, Add Course, and Add Manager columns now work
on two levels:

┌─────────────────────────────────────────────────────────────────┐
│  Column header (clickable)  →  opens a blank add form           │
│  Cell value   (clickable)   →  opens the add form pre-filled    │
│                                with the catalog already selected │
└─────────────────────────────────────────────────────────────────┘
Element What you see Where it goes
Column header Add Learner / Add Course / Add Manager link Generic add form — no catalog pre-selected
Cell value Learner count · Course count · Manager username(s) Add form with the catalog field already filled in

Visual flow:

 ┌──────────────┬─────────────┬──────────────┐
 │ [Add Learner]│ [Add Course]│ [Add Manager]│  ← header links (blank form)
 ├──────────────┼─────────────┼──────────────┤
 │     [42]     │    [10]     │   [jsmith]   │  ← cell links  (pre-filled)
 │     [0]      │    [5]      │     [—]      │
 └──────────────┴─────────────┴──────────────┘
  • Learner and course cells show the count as the link text.
  • Manager cells show the active manager's username as the link text,
    or if no active manager is assigned.
  • Multiple active managers are listed one per line.

Why a custom admin template was added

Django admin assigns CSS classes to table cells automatically
(.field-<method_name> for <td>, .column-<method_name> for <th>),
but there is no way to set text-align on those cells from inside the
cell's own HTML. Any inline style placed on the <a> or wrapper element
inside the cell only affects that inner element — it cannot reach the
<td> or <th> container.

To center the column headers and cell values without touching global
admin CSS, we added a minimal template override:

partner_catalog/templates/admin/partner_catalog/partnercatalog/change_list.html

This file extends Django's stock admin/change_list.html and injects a
small <style> block scoped to #result_list that targets only the
three affected columns:

#result_list .column-add_learner,
#result_list .column-add_course,
#result_list .column-add_manager,
#result_list .field-add_learner,
#result_list .field-add_course,
#result_list .field-add_manager {
  text-align: center;
}

The template is placed in the app's own templates/ directory and is
scoped to the partnercatalog change list only, so it has no effect on
any other admin view.

ccantillo added 6 commits July 2, 2026 17:18
- Merge the separate Courses/Learners count columns into the Add Course/Add Learner
  columns so each cell displays the count above the action link, reducing column clutter
- Update Add Manager column to show active manager usernames above the action link
  so admins can see at a glance who is managing each catalog
- Prefetch catalog_managers__user in the queryset to avoid N+1 queries
…label

Replace the count+link stacked cell with a single clickable element:
the learner and course counts become the link to add a new item, and
the manager username(s) become the link to add a new manager. When no
manager is assigned a dash link is shown. Column headers remain
'Add Learner', 'Add Course', 'Add Manager'.
Column headers Add Learner, Add Course and Add Manager are now
clickable links pointing to the respective add forms. Row cells
show only the plain count (learners, courses) or the active
manager usernames, with no extra link in the cell.
Header links go to the general add form; cell links (count for
learners/courses, username for managers) go to the add form
pre-filled with the catalog. Manager cells without an active
manager show a dash link to the add form.
@ccantillo
ccantillo requested a review from ManuelStarDo July 3, 2026 17:10
@ccantillo
ccantillo marked this pull request as ready for review July 3, 2026 17:10
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.

1 participant