1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-21 01:48:21 +02:00

🐛 WEI members must be members of the Kfet club *this year*

This commit is contained in:
Yohann D'ANELLO
2020-08-03 23:55:01 +02:00
parent ba067f050e
commit 20ce817b16
5 changed files with 89 additions and 106 deletions

View File

@ -531,7 +531,12 @@ class ClubAddMemberView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView):
return super().form_invalid(form)
if club.parent_club is not None:
if not Membership.objects.filter(user=form.instance.user, club=club.parent_club).exists():
if not Membership.objects.filter(
user=form.instance.user,
club=club.parent_club,
date_start__lte=form.instance.date_start,
date_end__gte=form.instance.date_start,
).exists():
form.add_error('user', _('User is not a member of the parent club') + ' ' + club.parent_club.name)
return super().form_invalid(form)