diff --git a/kfet/forms.py b/kfet/forms.py index 17add53b..2127e05b 100644 --- a/kfet/forms.py +++ b/kfet/forms.py @@ -4,6 +4,7 @@ from django.contrib.auth.models import User, Group, Permission from django.contrib.contenttypes.models import ContentType from django.contrib.admin.widgets import FilteredSelectMultiple from django.forms import modelformset_factory +from django.utils import timezone from kfet.models import (Account, Checkout, Article, OperationGroup, Operation, CheckoutStatement, ArticleCategory) from gestioncof.models import CofProfile @@ -161,7 +162,9 @@ class ArticleRestrictForm(ArticleForm): class KPsulOperationGroupForm(forms.ModelForm): checkout = forms.ModelChoiceField( - queryset = Checkout.objects.filter(is_protected=False), + queryset = Checkout.objects.filter( + is_protected=False, valid_from__lte=timezone.now(), + valid_to__gte=timezone.now()), widget = forms.HiddenInput()) class Meta: model = OperationGroup @@ -184,7 +187,9 @@ class KPsulAccountForm(forms.ModelForm): class KPsulCheckoutForm(forms.Form): checkout = forms.ModelChoiceField( - queryset=Checkout.objects.filter(is_protected=False), + queryset=Checkout.objects.filter( + is_protected=False, valid_from__lte=timezone.now(), + valid_to__gte=timezone.now()), widget=forms.Select(attrs={'id':'id_checkout_select'})) class KPsulOperationForm(forms.ModelForm): diff --git a/kfet/templates/kfet/checkout.html b/kfet/templates/kfet/checkout.html index 43d19950..55db6136 100644 --- a/kfet/templates/kfet/checkout.html +++ b/kfet/templates/kfet/checkout.html @@ -12,7 +12,7 @@