Fix deleting courses and codes (coursecodes FK constraint) - #1238
Merged
Merged
Conversation
Deleting a course or a code in Classes -> Courses / Codes failed on coursecodes foreign key constraint (ON DELETE RESTRICT). - deleting a course deletes its coursecodes too, course assigned to a class or a run is not deleted and readable message is shown - code used in a course is not deleted, message lists the courses - checks are done before rows are removed from the model, so the view stays consistent when delete is refused - TableView::setRemoveRowsQuestion() for custom delete confirmation, used for courses and codes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fvacek
approved these changes
Oct 4, 2026
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.
Fixes #1237
Deleting a course in Classes → Courses or a code in Classes → Codes failed on the
coursecodesforeign key constraint (ON DELETE RESTRICT), because both dialogs used a plainSqlTableModelwhich only runsDELETE FROM courses/codes WHERE id=….Changes
EditCoursesWidget): deleting a course deletes itscoursecodesrows in the same transaction. A course still assigned to a class (classdefs.courseId) or a run (runs.courseId) is not deleted, the user gets a readable message (class names + stage, or run count) instead of an SQL error.EditCodesWidget): a code used in a course is not deleted, the message lists the courses using it (first 10 + "and N more").dropRows()beforebeginRemoveRows(), so a refused delete does not leave the view showing the row as removed.TableView::setRemoveRowsQuestion()to replace the generic "Do you really want to remove row?" question. Courses ask "Do you really want to delete N course(s) including their codes? This cannot be undone.", codes ask a similar question. Default button stays No.Testing
coursecodes,classdefs.courseId,runs.courseId.🤖 Generated with Claude Code