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

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

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).

Summary ID
Fix the defaults around the Save buttons in Settings/Model Change forms.
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.
72a5b853354651e81d43fb234596fe4157e9a268
Description From Last Updated

E127 continuation line over-indented for visual indent

reviewbotreviewbot

Missing a colon here.

daviddavid
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
chipx86
david
  1. 
      
  2. Missing a colon here.

  3. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-4.0.x (73aeba2)
Loading...