Browse Source

separate confirm status for each role or user

pull/1473/head
youichiro 3 years ago
parent
commit
263deb238a
1 changed files with 8 additions and 1 deletions
  1. 9
      backend/api/serializers.py

9
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

Loading…
Cancel
Save