datatracker icon indicating copy to clipboard operation
datatracker copied to clipboard

feat: style admin site in dev mode

Open jennifer-richards opened this issue 1 year ago • 5 comments

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 avatar Jul 03 '24 23:07 jennifer-richards

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 avatar Jul 04 '24 12:07 jennifer-richards

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

jennifer-richards avatar Jul 08 '24 18:07 jennifer-richards

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.

jennifer-richards avatar Jul 09 '24 15:07 jennifer-richards

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.

jennifer-richards avatar Jul 09 '24 23:07 jennifer-richards

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 :warning:
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     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jul 10 '24 00:07 codecov[bot]