Skip to content

feat(admin): new Django admin dashboard landing page#4665

Open
marcoacierno wants to merge 1 commit into
mainfrom
worktree-new-django-admin-main-ui
Open

feat(admin): new Django admin dashboard landing page#4665
marcoacierno wants to merge 1 commit into
mainfrom
worktree-new-django-admin-main-ui

Conversation

@marcoacierno
Copy link
Copy Markdown
Member

What

Replaces the stock Django admin index (/admin/ — alphabetical app/model table) with a modern dashboard landing page, rendered as an Astro/React overlay using the existing custom-admin pattern.

Built spec-driven — see specs/django-admin-landing-page.md.

How

Backend (backend/custom_admin/)

  • index.py overrides admin.site.index (no AdminSite subclass / re-registration needed).
    • Buckets the ~69 registered models into 9 workflow groups (Program, Schedule & Video, Finance, Sponsors, People, Conference setup, Content & CMS, Comms, System) + an Other catch-all so no model is ever dropped (test-enforced).
    • Builds quick-action links: schedule builder (latest conference), review grants, review submissions.
    • Renders astro/landing.html with JSON-safe groups / all_apps / quick_links context.
  • admin.py wires install_custom_index().

Frontend (backend/custom_admin/src/)

  • pages/landing.astro passes props via to_json_for_prop.
  • components/landing/: root (Base/Apollo + DjangoAdminLayout), dashboard, group-card, quick-actions, stat-card (placeholder), all-models (collapsible fallback), types.

Tests / checks

  • 5 pytest tests: grouping, every model exactly once, Other catch-all, quick-link resolution, context JSON-serializable.
  • ruff + biome clean (pre-commit passed).

Not done yet

  • Stats data — cards show placeholder ; wiring real numbers via /admin/graphql is a deliberate follow-up.
  • Browser verification — not run from the worktree (needs full docker-compose up + codegen). Reviewer should confirm /admin/ renders and other proxied Astro pages (schedule-builder etc.) still work, and that pnpm build succeeds.

Open questions

  • Group membership tweaks welcome (easy to move models in index.py GROUPS).
  • Add more quick actions (e.g. invitation-letter document builder)?

🤖 Generated with Claude Code

Replace the stock admin index (alphabetical app/model table) with an
Astro/React dashboard rendered via the existing custom-admin overlay.

Backend:
- custom_admin/index.py overrides admin.site.index, bucketing registered
  models into 9 workflow groups (+ Other catch-all so nothing is dropped),
  builds quick-action links (schedule builder, grants, submissions), and
  renders astro/landing.html with JSON-safe context.
- tests cover grouping, exhaustive coverage, catch-all, link resolution and
  JSON serializability.

Frontend (custom_admin Astro app):
- pages/landing.astro + components/landing/* (root, dashboard, group cards,
  quick actions, placeholder stat cards, collapsible all-models fallback).

Stats values are placeholders; wiring real data via /admin/graphql is a
follow-up. Spec in specs/django-admin-landing-page.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pycon Error Error Jun 2, 2026 2:37pm

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Jun 2, 2026

Replaces Django's stock admin index with a custom Astro/React dashboard landing page. The overall approach is consistent with the existing custom-admin pattern.

Error Handling

_latest_schedule_builder_url() has no DB exception handling (index.py ~line 224–230). Conference.objects.order_by('-start').first() runs on every /admin/ hit with no try/except. A transient DB error raises an unhandled OperationalError on the landing page. The existing _safe_reverse helper shows the defensive intent — the DB call deserves the same treatment.

Architecture

GROUPS keyed by object_name alone (index.py lines 21–104) creates a latent collision risk. Two apps can register models with the same object_name (e.g. Page). Django's canonical identifier is app_label.object_name (_meta.label). The existing test test_every_registered_model_appears_exactly_once would detect a collision after the fact, but the key format should prevent it up front.

_model_to_group() is recomputed on every build_groups() call (index.py line 143). GROUPS is a module-level constant that never changes. This reverse-mapping should be built once — either as a module-level constant or with @functools.lru_cache().

install() ordering dependency is undocumented (index.py line 252). admin.site.index = custom_index works because it runs before Django calls get_urls() (which captures self.index in a closure). This is a fragile ordering assumption — it should be documented in the function or moved to AppConfig.ready().

Testing

All tests run as superuser — the admin_request fixture forces is_superuser=True. There is no test for a staff user with limited permissions to verify build_groups handles a partial app_list correctly and doesn't surface unauthorized models.

test_quick_links_resolve_to_urls doesn't assert the schedule builder link (test_index.py line 76–83). _latest_schedule_builder_url() has a fallback to the changelist URL when no Conference exists (which is the case in this test). The fallback path could be asserted.

Performance

build_all_apps and build_groups both iterate app_list and call _clean_model independently (index.py lines 136–168), so _clean_model is called ~2x per model per page load. The cleaned model dicts could be shared between the two functions.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

Codecov Report

❌ Patch coverage is 87.50000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.50%. Comparing base (5d8f9c3) to head (cc657ff).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4665      +/-   ##
==========================================
- Coverage   92.52%   92.50%   -0.03%     
==========================================
  Files         359      360       +1     
  Lines       10800    10856      +56     
  Branches      821      829       +8     
==========================================
+ Hits         9993    10042      +49     
- Misses        696      699       +3     
- Partials      111      115       +4     
🚀 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.

@marcoacierno
Copy link
Copy Markdown
Member Author

/deploy

@marcoacierno marcoacierno deployed to pastaporto June 2, 2026 14:50 — with GitHub Actions Active
@marcoacierno
Copy link
Copy Markdown
Member Author

WIP:

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.

1 participant