Skip to content

feat: delete a single Lab field version from history modal#281

Merged
italovalcy merged 1 commit into
mainfrom
feat/delete-field-version
Jul 11, 2026
Merged

feat: delete a single Lab field version from history modal#281
italovalcy merged 1 commit into
mainfrom
feat/delete-field-version

Conversation

@italovalcy

@italovalcy italovalcy commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

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-colors and it only shows the delete changes. Merge #280 first.

Changes

  • Frontend (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 as title tooltips. History-loading logic was extracted into a reusable loadFieldHistory() so the table can re-render after a delete.
  • API (routes.py): DELETE /api/labs/<lab_id>/field_versions/<field>/<version>, reusing the existing _get_lab_for_versions access rules (admin/teacher any lab, labcreator own labs only, students denied); 400 for unknown field, 404 for missing lab/version.
  • Controller (lab_versions.py): delete_version() helper.

Tests

New TestVersionDelete class in tests/test_lab_field_versions.py covering 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

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>
Base automatically changed from feat/issue-276-field-version-colors to main July 11, 2026 09:12
@italovalcy italovalcy marked this pull request as ready for review July 11, 2026 09:15
@italovalcy italovalcy merged commit 8c94ea9 into main Jul 11, 2026
3 checks passed
@italovalcy italovalcy deleted the feat/delete-field-version branch July 11, 2026 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

delete a snapshot in lab version

1 participant