weblate icon indicating copy to clipboard operation
weblate copied to clipboard

Fix IntegrityError when redirected from a Component, Category, and Project delete action

Open harriebird opened this issue 6 months ago • 6 comments

Proposed changes

Issue #12293 is caused by prefetching records that are related to the deleted Component, Category, or Project. To solve this, a boolean field to_delete is added to the Component, Category, and Project models. The to_delete field will help determine those records that are to be deleted and exclude them in the prefetch. This solves issue #12293.

Checklist

  • [ ] Lint and unit tests pass locally with my changes.
  • [ ] I have added tests that prove my fix is effective or that my feature works.
  • [ ] I have added documentation to describe my feature.
  • [ ] I have squashed my commits into logic units.
  • [ ] I have described the changes in the commit messages.

Other information

Summary by CodeRabbit

  • New Features

    • Introduced a soft delete mechanism for categories, components, and projects, allowing for better data management without permanent deletion.
    • Added functionality to mark related categories and components for deletion when a project is removed.
  • Bug Fixes

    • Enhanced data integrity by ensuring that only active categories and projects are fetched, excluding those marked for deletion.
  • Refactor

    • Improved prefetching logic to optimize database queries by excluding deleted items from related objects.
    • Refined project access filtering to enhance the accuracy of the project access list.
  • Chores

    • Updated view functions to incorporate new filtering criteria for active categories and components.

harriebird avatar Aug 27 '24 20:08 harriebird