fix(admin): keep base_catalog pre-filled after save and add another#63
Open
ccantillo wants to merge 3 commits into
Open
fix(admin): keep base_catalog pre-filled after save and add another#63ccantillo wants to merge 3 commits into
ccantillo wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
sticky base_catalog on "Save and add another"
Keep the Base catalog field pre-filled when an admin clicks
"Save and add another" in the
BaseCatalogCourseadmin page.Context
Related issue: sticky base_catalog after save-and-add-another in
/admin/partner_catalog/basecatalog/.When adding multiple courses to the same
BaseCatalogone by one,clicking "Save and add another" redirected to a blank add form,
forcing the user to re-select the catalog every time. The only
workarounds were going back to the previous page or copy-pasting
the catalog ID manually.
Root cause
Django admin's default
response_addredirect to/add/does notcarry any query parameters, so the
base_catalograw-id field isalways empty on the next form load.
Change
Two small overrides added to
BaseCatalogCourseAdmininpartner_catalog/admin.py:response_add— when_addanotheris in the POST data,redirects to
/add/?base_catalog=<id>instead of the plain/add/,preserving the catalog that was just used.
get_changeform_initial_data— reads thebase_catalogGETparameter and injects it into the form's initial data so the
raw-id widget renders with the value already set.