Commit 9fbf1700 authored by chirac's avatar chirac

Merge branch 'solde-users' into 'dev'

Solde users

See merge request federez/re2o!273
parents 175e2170 33319994
...@@ -243,12 +243,12 @@ class RechargeForm(FormRevMixin, Form): ...@@ -243,12 +243,12 @@ class RechargeForm(FormRevMixin, Form):
label=_("Payment method") label=_("Payment method")
) )
def __init__(self, *args, user=None, **kwargs): def __init__(self, *args, user=None, user_source=None, **kwargs):
self.user = user self.user = user
super(RechargeForm, self).__init__(*args, **kwargs) super(RechargeForm, self).__init__(*args, **kwargs)
self.fields['payment'].empty_label = \ self.fields['payment'].empty_label = \
_("Select a payment method") _("Select a payment method")
self.fields['payment'].queryset = Paiement.find_allowed_payments(user).exclude(is_balance=True) self.fields['payment'].queryset = Paiement.find_allowed_payments(user_source).exclude(is_balance=True)
def clean(self): def clean(self):
""" """
......
...@@ -827,7 +827,7 @@ def credit_solde(request, user, **_kwargs): ...@@ -827,7 +827,7 @@ def credit_solde(request, user, **_kwargs):
kwargs={'userid': user.id} kwargs={'userid': user.id}
)) ))
refill_form = RechargeForm(request.POST or None, user=request.user) refill_form = RechargeForm(request.POST or None, user=user, user_source=request.user)
if refill_form.is_valid(): if refill_form.is_valid():
price = refill_form.cleaned_data['value'] price = refill_form.cleaned_data['value']
invoice = Facture(user=user) invoice = Facture(user=user)
...@@ -854,7 +854,7 @@ def credit_solde(request, user, **_kwargs): ...@@ -854,7 +854,7 @@ def credit_solde(request, user, **_kwargs):
p = get_object_or_404(Paiement, is_balance=True) p = get_object_or_404(Paiement, is_balance=True)
return form({ return form({
'factureform': refill_form, 'factureform': refill_form,
'balance': request.user.solde, 'balance': user.solde,
'title': _("Refill your balance"), 'title': _("Refill your balance"),
'action_name': _("Pay"), 'action_name': _("Pay"),
'max_balance': p.payment_method.maximum_balance, 'max_balance': p.payment_method.maximum_balance,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment