1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-11-26 18:37:12 +00:00

Check that the user is a member of the parent club only at the creation of the membership

This commit is contained in:
Yohann D'ANELLO 2020-08-15 23:52:57 +02:00
parent 4997a37058
commit 9f258e39b6

View File

@ -384,7 +384,8 @@ class Membership(models.Model):
).exists():
raise ValidationError(_('User is already a member of the club'))
if self.club.parent_club is not None:
if self.club.parent_club is not None and not self.pk:
# Check that the user is already a member of the parent club if the membership is created
if not Membership.objects.filter(
user=self.user,
club=self.club.parent_club,