From 98a30f421502748a7606b143794e164c1ccae9d1 Mon Sep 17 00:00:00 2001 From: nanoy Date: Sun, 16 Dec 2018 11:20:02 +0100 Subject: [PATCH] Fix is_usable_in_cotisation Close #15 --- gestion/forms.py | 2 +- users/forms.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gestion/forms.py b/gestion/forms.py index da007cf..3a45780 100644 --- a/gestion/forms.py +++ b/gestion/forms.py @@ -11,7 +11,7 @@ from coopeV3.widgets import SearchField class ReloadForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(ReloadForm, self).__init__(*args, **kwargs) - self.fields['PaymentMethod'].queryset = PaymentMethod.objects.filter(is_usable_in_reload=True) + self.fields['PaymentMethod'].queryset = PaymentMethod.objects.filter(is_usable_in_reload=True).filter(is_active=True) class Meta: model = Reload diff --git a/users/forms.py b/users/forms.py index 4fea80f..b4942f5 100644 --- a/users/forms.py +++ b/users/forms.py @@ -2,6 +2,7 @@ from django import forms from django.contrib.auth.models import User, Group from dal import autocomplete from .models import School, CotisationHistory, WhiteListHistory +from preferences.models import PaymentMethod class LoginForm(forms.Form): """ @@ -84,6 +85,10 @@ class addCotisationHistoryForm(forms.ModelForm): """ Form to add a cotisation to user """ + def __init__(self, *args, **kwargs): + super(addCotisationHistoryForm, self).__init__(*args, **kwargs) + self.fields['paymentMethod'].queryset = PaymentMethod.objects.filter(is_usable_in_cotisation=True).filter(is_active=True) + class Meta: model = CotisationHistory fields = ("cotisation", "paymentMethod")