Extend deletion guards to all non-archived versions and add bulk-archive action#3198
Open
claude[bot] wants to merge 1 commit into
Open
Extend deletion guards to all non-archived versions and add bulk-archive action#3198claude[bot] wants to merge 1 commit into
claude[bot] wants to merge 1 commit into
Conversation
… action Working and published experiment versions already blocked deletion of referenced service providers, assistants, pipelines, and collections. Non-published snapshot versions (not working, not published, not archived) were silently ignored, letting deletions corrupt those references. Changes: - Add `is_blocking_object` / `is_bulk_archiveable` helpers in `apps/utils/deletion.py` - Update `get_related_experiments_queryset` methods in assistants, documents, and service-provider views to return ALL non-archived versions, not just working/published - Categorise blocking references in every delete view into "manual-only" (working + published) and "bulk-archiveable" (non-working, non-published, non-archived) - Add `bulk_archive_experiment_versions` endpoint (`experiments:bulk_archive_versions`) that archives a supplied list of non-working, non-published versions atomically - Update `templates/generic/referenced_objects.html` to show the bulk-archive section with a form button when bulk-archiveable versions exist - Add comprehensive tests for deletion blocking and bulk-archive endpoint Co-Authored-By: Claude Sonnet 4.6 <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.
Product Description
When a service provider, assistant, pipeline, or collection is deleted, the UI now correctly blocks deletion if any non-archived experiment version references the object — including non-working, non-published snapshot versions that were previously silently ignored.
The "Cannot delete" modal now also shows a "Archive All Non-published Versions" button for non-working, non-published versions, so users can bulk-archive those references in one click instead of navigating to each version manually. Working and published versions still require manual cleanup.
Technical Description
Added
is_blocking_object(obj)andis_bulk_archiveable(obj)helpers inapps/utils/deletion.pyis_blocking_object: any non-archived object blocks deletionis_bulk_archiveable: non-working (working_version_idis set), non-published (is_default_version=False), non-archived — eligible for the bulk actionUpdated
get_related_experiments_queryset/get_related_experiments_with_pipeline_querysetinapps/assistants/models.pyandapps/documents/models.pyto return all non-archived versions (not only working/published)Updated every delete view (
apps/service_providers/views.py,apps/assistants/views.py,apps/documents/views.py,apps/pipelines/views.py) to:bulk_archiveable_experiments/bulk_archiveable_ids/bulk_archive_urlto the modal templateAdded
bulk_archive_experiment_versionsview (POST experiments/versions/bulk-archive/) that atomically archives a list of non-working, non-published versions scoped to the teamUpdated
templates/generic/referenced_objects.htmlto render a "Non-published versions" section with the bulk-archive form when applicableMigrations
No migrations — only logic changes.
Demo
Docs and Changelog
Closes #3197
🤖 Generated with Claude Code