Add a special Django AdminSite and ModelAdmin classes.
Review Request #11038 — Created May 27, 2020 and submitted
The Review Board administration UI has historically been built on top of
the Django admin UI, with a lot of customizations wrapping that
foundation. Review Board 4.0 has been moving away from the Django admin
UI, while retaining compatibility with it. Still, there are aspects of
it that we depend on, but need to customize, and the safest way to do
that is by using the support built into it rather than attempting to
work around it.To help with that, this change introduces a new
AdminSite
of our own,
which has some information overridden and new functionality added.
AdminSite
controls all the views and settings for the administration
UI, and Django normally provides one that we can use. By providing our
own, we're able to fix up some wording in places, and reuse some
capabilities of our normal Review Board login form when users try
logging into the admin UI.While Django does allow for custom admin UIs, it doesn't really expect
the main one to be replaced.ModelAdmin
s are still generally
registered with the main one. Because of that, ourAdminSite
actually
shares all the same registration state as the main one. It's a hack, but
we gain enough to justify it.We also provide a new
ModelAdmin
"base class." This is a very simple
subclass of the Django's ownModelAdmin
, which currently provides a
documented field that can be overridden for the fieldset template
(something that was available in our new admin UI but not well
documented).Going forward, all new
ModelAdmin
subclasses should use our new one as
the base class. We'll continue to support Django's version, but using
our own will lead to advantages in customizing behavior in the
administration UI.This also gets rid of the model auto-discovery, which is no longer
needed.
All unit tests pass.
Tested the functionality of the administration UI to make sure things
are still working as expected.Tested that the new login form works as expected.
Compared the list of available models in the database section with this
change and without it, making sure we didn't lose anything but disabling
the auto-discovery.
Summary | ID |
---|---|
16b6578970e06ba1441f4bfb74984b8736b7501b |