forked from DGNum/gestioCOF
Utilise des callables pour les choix
This commit is contained in:
parent
f70eacfc37
commit
2d677b2093
1 changed files with 4 additions and 5 deletions
|
@ -55,17 +55,16 @@ def default_promo():
|
||||||
return now.month <= 8 and now.year - 1 or now.year
|
return now.month <= 8 and now.year - 1 or now.year
|
||||||
|
|
||||||
|
|
||||||
PROMO_CHOICES = [("", "Sans promo")] + [
|
def get_promo_choices():
|
||||||
(r, r) for r in range(1980, date.today().year + 1)
|
return [("", "Sans promo")] + [(r, r) for r in range(1980, date.today().year + 1)]
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class AccountForm(forms.ModelForm):
|
class AccountForm(forms.ModelForm):
|
||||||
promo = forms.TypedChoiceField(
|
promo = forms.TypedChoiceField(
|
||||||
choices=PROMO_CHOICES,
|
choices=get_promo_choices,
|
||||||
coerce=int,
|
coerce=int,
|
||||||
empty_value=None,
|
empty_value=None,
|
||||||
initial=default_promo(),
|
initial=default_promo,
|
||||||
required=False,
|
required=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue