Fix the defaults around the Save buttons in Settings/Model Change forms.

Review Request #11344 — Created Dec. 23, 2020 and submitted — Latest diff uploaded

Information

Review Board
release-4.0.x

Reviewers

The new template for the change forms tried to use defaults if variables
for controlling the presence of the Save buttons weren't provided.
However, it did this using |default:True, which meant that a value of
False would be turned into True. Not what we wanted.

That, however, was put in place (in change 663f50d) in order to fix a
prior (incorrect) attempt that used |default_if_none. That could have
worked if that filter considered a missing variable to be equivalent to
None, but it didn't.

Even with these attempts, we had two code paths for generating that
template: Ours, and Django's, depending on whether a change form was
being rendered.

This change implements a more future-proof, reliable attempt at
generating these buttons. We now have a dedicated template tag that
covers the logic in Django's own submit_row template tag and our own
logic, and expands upon that to allow greater customization by callers
(a Delete button is now possible without the rest of the admin classes).

With this, the Settings forms and Model Change forms all now show the
correct buttons.

Tested all the Settings forms, various model change forms, and the
integrations/extensions forms (which use their own templates anyway).

Commits

Files

    Loading...