From 263deb238a2c21d394a8ad1df91c2435463a6fc1 Mon Sep 17 00:00:00 2001 From: youichiro Date: Wed, 18 Aug 2021 21:52:00 +0900 Subject: [PATCH] separate confirm status for each role or user --- backend/api/serializers.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/api/serializers.py b/backend/api/serializers.py index 4dfbf78c..ca188199 100644 --- a/backend/api/serializers.py +++ b/backend/api/serializers.py @@ -101,7 +101,14 @@ class ExampleSerializer(serializers.ModelSerializer): return approver.username if approver else None def get_is_confirmed(self, instance): - return instance.states.count() > 0 + user = self.context.get('request').user + if instance.project.collaborative_annotation: + current_user_role = RoleMapping.objects.get(user_id=user.id, project_id=instance.project.id).role + state_ids = [state.id for state in instance.states.all() if state.confirmed_user_role == current_user_role] + states = instance.states.filter(id__in=state_ids) + else: + states = instance.states.filter(confirmed_by_id=user.id) + return states.count() > 0 class Meta: model = Example