Harden admin tree state sync and add strict admin mode#43
Merged
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.
Motivation
Description
TREENODE_STRICT_ADMIN_MODEsetting (treenode/settings.py) to enable a strict admin mode that disables client-sidelocalStoragerestoration of expanded state.data-strict-admin-modeon the#changelistcontainer and injected the flag from the admin view (treenode/admin/admin.py->changelist_view).getTreeSignature()intreenode/static/treenode/js/treenode_admin.jsto include row order (index) anddata-path(_path) and readdata-strict-admin-mode; in strict mode the JS drops the stored state instead of restoring it.move/AJAX call the client now removes the model-scoped expanded-state key fromlocalStoragebefore callinglocation.reload()to avoid restoring stale state (treenode_admin.js).data-path(from_path) and use_depthdirectly in server-rendered rows for both initial and AJAX row rendering by updatingAdminMixinand AJAX row template (treenode/admin/mixin.py,treenode/templates/treenode/admin/treenode_ajax_rows.html).tn_children_count=Count('children')and using that annotated value (with fallback) for toggle/icon decisions and by using_depthfor indentation (treenode/admin/admin.py,treenode/templatetags/treenode_admin.py).Testing
python -m compileall treenodeto validate Python files compile successfully (succeeded).python -m django test treenode.testsbut it failed in this environment becauseDJANGO_SETTINGS_MODULEis not configured (test runner not available here).pytest -qbutpytest-djangocould not auto-discover a Django project in this environment (nomanage.py/ configured project), so full test run was not possible here.Codex Task