Browse Source

Update validation in role mapping

pull/1627/head
Hironsan 2 years ago
parent
commit
b40772eb41
1 changed files with 3 additions and 4 deletions
  1. 7
      backend/roles/models.py

7
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')
Loading…
Cancel
Save