Club managers can register new members to a club, even if they don't have the right to create a transaction

This commit is contained in:
Yohann D'ANELLO 2020-07-31 09:49:43 +02:00
parent cb38ceb2c6
commit 72dcc93136
2 changed files with 6 additions and 1 deletions

View File

@ -568,7 +568,7 @@ class ClubAddMemberView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView):
form.add_error('bank', _("This field is required.")) form.add_error('bank', _("This field is required."))
return self.form_invalid(form) return self.form_invalid(form)
SpecialTransaction.objects.create( transaction = SpecialTransaction(
source=credit_type, source=credit_type,
destination=user.note, destination=user.note,
quantity=1, quantity=1,
@ -579,11 +579,14 @@ class ClubAddMemberView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView):
bank=bank, bank=bank,
valid=True, valid=True,
) )
transaction._force_save = True
transaction.save()
ret = super().form_valid(form) ret = super().form_valid(form)
member_role = Role.objects.filter(name="Membre de club").all() member_role = Role.objects.filter(name="Membre de club").all()
form.instance.roles.set(member_role) form.instance.roles.set(member_role)
form.instance._force_save = True
form.instance.save() form.instance.save()
# If Société générale pays, then we assume that this is the BDE membership, and we auto-renew the # If Société générale pays, then we assume that this is the BDE membership, and we auto-renew the
@ -607,6 +610,7 @@ class ClubAddMemberView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView):
date_start=old_membership.get().date_end + timedelta(days=1) date_start=old_membership.get().date_end + timedelta(days=1)
if old_membership.exists() else form.instance.date_start, if old_membership.exists() else form.instance.date_start,
) )
membership._force_save = True
membership._soge = True membership._soge = True
membership.save() membership.save()
membership.refresh_from_db() membership.refresh_from_db()

View File

@ -2372,6 +2372,7 @@
22, 22,
47, 47,
49, 49,
50,
140 140
] ]
} }