feat(modtools): bulk versionTitle rename#3197
Open
dcschreiber wants to merge 3 commits intofeature/sc-36475/modtools-pr1-backendfrom
Open
feat(modtools): bulk versionTitle rename#3197dcschreiber wants to merge 3 commits intofeature/sc-36475/modtools-pr1-backendfrom
dcschreiber wants to merge 3 commits intofeature/sc-36475/modtools-pr1-backendfrom
Conversation
Add the ability to rename versionTitle across multiple indices in the bulk version editor. This was previously blocked because versionTitle is part of the Version model's composite primary key, but the model layer already supports renaming via track_pkeys + dependency handlers. Backend: - Extend version_bulk_edit_api to accept optional newVersionTitle - Pre-check for duplicates across all indices before any modification - Apply metadata updates first, then rename (two-phase per version) - Version.save() fires existing attributeChange handlers automatically New cascade handlers for versionTitle changes: - marked_up_text_chunks + linker_output (versionTitle is a pkey) - links.charLevelData + links.versions (essay-type) - topic_links.charLevelData - user_history.versions - profiles.version_preferences_by_corpus Frontend: - Add "New Version Title" input in Version Identification section - Confirmation dialog listing side effects before rename - Auto-refresh search with new title after successful rename - Partial success messaging for rename operations - Changes preview shows rename operation Tests: - Rename succeeds across multiple indices - Duplicate detection rejects conflicting renames - Combined rename + field updates - Empty/same title validation - Cascade to marked_up_text_chunks and links.charLevelData Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add explicit CSRF token check before sending the upload request, and handle 403 responses with a user-friendly message suggesting a page refresh. Complements the server-side @ensure_csrf_cookie fix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replaces the prior soft-delete ("mark for deletion") flow with a real
bulk delete endpoint: POST /api/version-bulk-delete now permanently
removes selected Versions and records each deletion via
record_version_deletion. The BulkVersionEditor's confirmation dialog
and help text are updated accordingly, and the index list refreshes
after a successful delete.
Also extracts versionTitle rename validation, conflict checking, and
cascading save into tracker.py helpers (validate_version_title_change,
check_version_title_conflicts, rename_version_title) so both
version_bulk_edit_api and the single-version flag_text_api go through
the same code path. flag_text_api now properly cascades a
newVersionTitle rename instead of writing it as a plain field update.
Docs (MODTOOLS_GUIDE, COMPONENT_LOGIC) updated to document the new
endpoint and the permanent-delete behavior.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Adds bulk versionTitle rename and bulk permanent delete to the Bulk Version Editor (modtools), and consolidates versionTitle-rename logic into shared
tracker.pyhelpers used by both the bulk and single-version (flag_text_api) endpoints.What's included
POST /api/version-bulk-editwithnewVersionTitle):Version.save()firesattributeChangehandlers viatrack_pkeys, cascading to history, search, links, topics, notifications, and user profiles.POST /api/version-bulk-delete):[MARKED FOR DELETION]note toversionNotes).record_version_deletion.sefaria/tracker.py:validate_version_title_change,check_version_title_conflicts,rename_version_title.version_bulk_edit_apiandflag_text_apinow go through the same code path.flag_text_apipreviously wrotenewVersionTitleas a plain field update; it now properly cascades.MODTOOLS_GUIDE.md,COMPONENT_LOGIC.md) updated for the new endpoint, the rename behavior, and the permanent-delete flow.Test plan
pytest sefaria/tests/modtools_test.py(rename + cascade tests already cover bulk-edit/rename — bulk-delete tests still TODO)flag_text_apiwithnewVersionTitlefor a single version and confirm it cascades the same way as bulk