✨(backend) allow to leave a document#2365
Open
lunika wants to merge 2 commits into
Open
Conversation
The mask feature has never been implemented by the frontend application and it is not what we want to do. We want to implement a feature to leave a document.
We want to allow users to leave a document where they have an access or they have visited creating a link_trace. All subdocuments should also be leaved at the same time. To know if the user can leave a doc we have to check when computing the abilities if a record is existing in the LinkTrace table. This is a N+1 query situation. To avoid it, we added an annotation in the DocumentQueryset like we already do to annotate the user role. There is one edge case where the annotation is made to soon, it is when the user is visiting a document for the first time, the `get_object` add the annotation and in the permission, we compute the abilities. The `leave` property is False because the entry in the LinkTrace table is not made, when the serializer ask for the abilities again, it is still False. So in the `retrieve` method in the viewset we force the `user_has_link_trace` to the correct value.
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.
Purpose
We want to allow users to leave a document where they have an access or
they have visited creating a link_trace. All subdocuments should also be
leaved at the same time.
To know if the user can leave a doc we have to check when computing the
abilities if a record is existing in the LinkTrace table. This is a N+1
query situation. To avoid it, we added an annotation in the
DocumentQueryset like we already do to annotate the user role.
There is one edge case where the annotation is made to soon, it is when the
user is visiting a document for the first time, the
get_objectadd theannotation and in the permission, we compute the abilities. The
leaveproperty is False because the entry in the LinkTrace table is not made,
when the serializer ask for the abilities again, it is still False. So
in the
retrievemethod in the viewset we force theuser_has_link_traceto the correct value.Proposal
Backend part of issue #708