Skip to content

Final Django Admin Removal - #445

Merged
SchoolGuy merged 7 commits into
masterfrom
feature/remove-django-admin
Aug 22, 2026
Merged

Final Django Admin Removal#445
SchoolGuy merged 7 commits into
masterfrom
feature/remove-django-admin

Conversation

@SchoolGuy

Copy link
Copy Markdown
Collaborator

This PR adds the missing functionality to get rid of the Django Admin completely. This is another step to prepare for the upcoming migration of Orthos 2 into Cobbler.

Adds a superuser-only Token list + revoke view, replacing the only
remaining reason to visit /admin/authtoken/tokenproxy/. Self-service
token regeneration for one's own account already existed; this adds
the "see/revoke anyone's token" admin-facing view.

Part of the Django Admin removal effort (A1/5).
Superusers auditing/revoking tokens need the full key, not a masked
prefix. Also add a "Tokens" tab on the User detail page so a token can
be found starting from the user rather than only from the global list.

Key the revoke URL on the token's owning user (Token.user is a
OneToOneField) instead of the token's own key, so the secret never
ends up in a URL and thus browser history / access logs.
Extends the existing read-only User list/detail with full superuser
account management: create (unusable password until a reset email is
sent), edit (username/email/name/flags/groups), deactivate/reactivate,
hard delete, and a "send password reset email" action. The reset
action is disabled for OIDC-linked accounts, which have no local
password to reset.

Replaces the last reason to visit /admin/auth/user/.

Part of the Django Admin removal effort (A2/5).
Adds a superuser-only list/detail/create/edit/delete for
django.contrib.auth.models.Group (name + permissions), for admin-app
parity. Nothing in Orthos2's own authorization logic checks group
membership today - this only replaces /admin/auth/group/ access.

Part of the Django Admin removal effort (A3/5).
Association and Nonce are ephemeral social-django bookkeeping tables
for the OIDC login handshake - never read or written by Orthos2 code
and not meant for hands-on editing. Adds a superuser-only, read-only
list of both for troubleshooting, without exposing Association.secret.

Part of the Django Admin removal effort (A4/5).
Users, Groups, Tokens, Associations, Nonces, and UserSocialAuths all
now have frontend equivalents (or an explicit no-UI decision for the
purely internal OIDC bookkeeping tables). Drop django.contrib.admin
from INSTALLED_APPS, the /admin/ URL include, the "Django Admin" nav
link, and the now-pointless empty admin.py files.

Completes the Django Admin removal effort (A5/5).
The dev DB/NetBox instance persists across container restarts, but
several startup steps in devel-server.sh/setup_netbox.py assumed a
fresh environment and blew up on every restart after the first:

- django-generate-admin-token used Token.objects.create() unconditionally,
  raising IntegrityError once the admin user already had a token
  (Token.user is a OneToOneField).
- devel-server.sh's two loaddata calls and createsuperuser errored with
  duplicate-key/"username already taken" once that data already existed.
- setup_netbox.py unconditionally re-POSTed ~50 objects to NetBox, most
  already caught by broad try/except but still spamming HTTP 400s (and
  the few uncaught ones, e.g. the site/device-role creation, would abort
  the script outright on a second run).

Guard each with an existence check (get_or_create for the token,
shell -c exit-code checks before the fixture/superuser commands, and a
netbox.check_site() early-return in setup_netbox.py) so re-running
against already-provisioned state is a no-op instead of an error.
@SchoolGuy SchoolGuy changed the title Final Djang Admin Removal Final Django Admin Removal Aug 22, 2026
@codacy-production

codacy-production Bot commented Aug 22, 2026

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 2 high · 17 minor

Alerts:
⚠ 19 issues (≤ 0 issues of at least minor severity)

Results:
19 new issues

Category Results
Documentation 17 minor
Security 2 high

View in Codacy

🟢 Metrics 101 complexity · 53 duplication

Metric Results
Complexity 101
Duplication 53

View in Codacy

🟢 Coverage 100.00% diff coverage · +0.67% coverage variation

Metric Results
Coverage variation +0.67% coverage variation (-1.00%)
Diff coverage 100.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (4e93e8f) 23012 17115 74.37%
Head commit (ebda194) 23634 (+622) 17737 (+622) 75.05% (+0.67%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#445) 631 631 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@SchoolGuy
SchoolGuy merged commit 5c58b70 into master Aug 22, 2026
14 of 15 checks passed
@SchoolGuy
SchoolGuy deleted the feature/remove-django-admin branch August 22, 2026 09:20
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