fix: Ignore soft-deleted memberships when querying if user belongs to project #874
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.
Description
This seems to be caused by #870 . When I was debugging this, it seems that the problem came from trying to match the fields created by the
ManyToManyField
(so here themembers
onmembership_list
, i.e.collaboration_memberships__membership_list
). The results don't seem to take into account thedeleted_at
field that marks if a membership has been soft deleted, and should be ignored from the query.For example, when I debug the test, if I retrieve the membership list for the project I'm trying to query, and then do
memb_list.members.all()
, the membership that has been deleted still shows up. So it seems to not be a problem with the filter itself, but perhaps the django-safedelete configuration of the models.The fix here is just to make a subquery that actually works. It would be nice to fix the underlying problem with the zombie memberships later too.
Checklist
Related Issues
Fixes #....
Verification steps