feat: delete a single Lab field version from history modal#281
Merged
Conversation
Add a Delete button to the Version History modal alongside Diff/View/ Restore (shortened labels, full text moved to tooltips). Backend adds a DELETE /api/labs/<lab>/field_versions/<field>/<version> endpoint guarded by the same access rules as the rest of the versions API, plus a delete_version controller helper. Covered by new tests for success, 404/400 cases, and permission denial. Co-Authored-By: Claude Opus 4.8 <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.
Fix #277
Summary
Adds the ability to delete an individual version from the Version History modal in the Lab editor.
Stacked on top of #280 (diff colors), so this PR's base is
feat/issue-276-field-version-colorsand it only shows the delete changes. Merge #280 first.Changes
labs_edit.html): new red-outlined Delete button per row (confirm dialog → DELETE request → refresh list). Shortened the other action labels — "Diff vs current" → "Diff", "Restore into editor" → "Restore" — to keep the actions column compact, with the full text preserved astitletooltips. History-loading logic was extracted into a reusableloadFieldHistory()so the table can re-render after a delete.routes.py):DELETE /api/labs/<lab_id>/field_versions/<field>/<version>, reusing the existing_get_lab_for_versionsaccess rules (admin/teacher any lab, labcreator own labs only, students denied); 400 for unknown field, 404 for missing lab/version.lab_versions.py):delete_version()helper.Tests
New
TestVersionDeleteclass intests/test_lab_field_versions.pycovering successful delete (only the target removed, other fields untouched), unknown-version 404, unknown-field 400, missing-lab 404, and permission denial for student and for labcreator on another user's lab. Full suite: 21 passed.Local Tests: to be executed