Skip to content

✨(backend) allow to leave a document#2365

Open
lunika wants to merge 2 commits into
mainfrom
feat/leave_a_doc
Open

✨(backend) allow to leave a document#2365
lunika wants to merge 2 commits into
mainfrom
feat/leave_a_doc

Conversation

@lunika
Copy link
Copy Markdown
Member

@lunika lunika commented May 29, 2026

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_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.

Proposal

  • 🔥(backend) remove masking document code
  • ✨(backend) allow to leave a document

Backend part of issue #708

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.
@lunika lunika self-assigned this May 29, 2026
@lunika lunika added the enhancement improve an existing feature label May 29, 2026
@lunika lunika force-pushed the feat/leave_a_doc branch from 85743c0 to b996eda Compare May 29, 2026 13:23
@lunika lunika requested a review from kernicPanel May 29, 2026 13:24
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.
@lunika lunika force-pushed the feat/leave_a_doc branch from b996eda to 1a231a1 Compare May 29, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement improve an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant