From b40772eb411949c52abf5defde4836973846d600 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Wed, 12 Jan 2022 14:57:46 +0900 Subject: [PATCH] Update validation in role mapping --- backend/roles/models.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/backend/roles/models.py b/backend/roles/models.py index fbaf19d6..21a3a382 100644 --- a/backend/roles/models.py +++ b/backend/roles/models.py @@ -62,11 +62,10 @@ class RoleMapping(models.Model): objects = RoleMappingManager() def clean(self): - other_rolemappings = self.project.role_mappings.exclude(id=self.id) - - if other_rolemappings.filter(user=self.user, project=self.project).exists(): + member_roles = self.objects.exclude(id=self.id) + if member_roles.filter(user=self.user, project=self.project).exists(): message = 'This user is already assigned to a role in this project.' raise ValidationError(message) class Meta: - unique_together = ("user", "project") + unique_together = ('user', 'project')