mirror of
https://github.com/suitenumerique/docs.git
synced 2026-10-01 05:55:16 +02:00
♻️(backend) annotate mentioned user roles in mention validation
Signed-off-by: BOUKERFA Mohamed El Amine <boukerfa.ma@gmail.com>
This commit is contained in:
@@ -1027,7 +1027,9 @@ class MentionSerializer(serializers.ModelSerializer):
|
||||
|
||||
def validate_mentioned_user_id(self, user):
|
||||
"""Ensure the mentioned user has access to the document."""
|
||||
document = models.Document.objects.get(pk=self.context["document"].pk)
|
||||
document = models.Document.objects.annotate_user_roles(user).get(
|
||||
pk=self.context["document"].pk
|
||||
)
|
||||
if document.get_role(user) is None:
|
||||
raise serializers.ValidationError(
|
||||
"This user does not have access to the document."
|
||||
|
||||
Reference in New Issue
Block a user