Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: dev mode admin + refactor api init #7628

Merged
merged 7 commits into from
Aug 7, 2024

Conversation

jennifer-richards
Copy link
Member

When in dev mode, applies styling to the Django admin site that resembles main site's dev mode. It also changes the admin title from "Django administration" to "Datatracker administration".

This introduces an admin app with an apps.py. This lets us override the title / header for the admin site without customizing more templates. In theory we could put the contents of the ietf/admin/ directory into an ietf/admin.py instead, but this does not play well with TastyPie's api autodiscovery. 😡

The CSS for this is a bit clunky - importing ietf.css to the admin does nasty things to its formatting. Instead, I've copied the explicit values for a few colors to try to keep the admin consistent with the overall scheme of the site. This is fragile and we could do it better, but I don't think it's worth much more effort.

@jennifer-richards jennifer-richards marked this pull request as draft July 4, 2024 12:57
@jennifer-richards
Copy link
Member Author

Converting to draft to figure out what to do about tests failing. They don't like an app with no models.py file. I'm going to revisit whether it's worth adding the customization this way.

@jennifer-richards
Copy link
Member Author

N.b., tests are now passing aside from the URL coverage

rjsparks
rjsparks previously approved these changes Jul 9, 2024
@jennifer-richards jennifer-richards marked this pull request as ready for review July 9, 2024 15:00
@jennifer-richards jennifer-richards marked this pull request as draft July 9, 2024 15:06
@jennifer-richards
Copy link
Member Author

Sorry for waffling about whether to leave this as a draft or not. I think that some of the pain I blamed TastyPie for might be self-induced. We have an autodiscover() method in ietf.api.__init__ that is based on a now long stale version of Django's admin module autodiscovery method. I want to try bringing that up to date with modern Django's method and see if it lets us avoid having to promote the admin customization to its own app.

Avoids interacting with the app registry before
it's ready.
@jennifer-richards
Copy link
Member Author

Ok - I think this is ready. The last commit (95ce3f8) brought the api init up to Django's spec for initializing things that pay attention to the app registry.

I've left the admin app as a fully fleshed out app. With the changes here, I could combine the files in ietf/admin/ into a single admin.py but I think we might as well follow the standard layout even if it's a minimal app.

Copy link

codecov bot commented Jul 10, 2024

Codecov Report

Attention: Patch coverage is 96.87500% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.79%. Comparing base (187c2c5) to head (467a338).
Report is 327 commits behind head on main.

Files Patch % Lines
ietf/admin/sites.py 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7628      +/-   ##
==========================================
- Coverage   88.98%   88.79%   -0.20%     
==========================================
  Files         291      298       +7     
  Lines       40717    41292     +575     
==========================================
+ Hits        36233    36664     +431     
- Misses       4484     4628     +144     

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

@jennifer-richards jennifer-richards changed the title feat: style admin site in dev mode feat: dev mode admin + refactor api init Jul 16, 2024
@rjsparks rjsparks merged commit 95a7e14 into ietf-tools:main Aug 7, 2024
9 checks passed
@jennifer-richards jennifer-richards deleted the safer-admin branch August 8, 2024 16:51
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants