forked from DGNum/gestioCOF
kfet -- Fix available checkouts in K-Psul
The checkout validity is checked using the current datetime (when requesting the kpsul page).
This commit is contained in:
parent
e23e1bdba6
commit
525bb4d16d
2 changed files with 17 additions and 8 deletions
|
@ -296,17 +296,17 @@ class KPsulAccountForm(forms.ModelForm):
|
|||
|
||||
class KPsulCheckoutForm(forms.Form):
|
||||
checkout = forms.ModelChoiceField(
|
||||
queryset=(
|
||||
Checkout.objects
|
||||
.filter(
|
||||
is_protected=False,
|
||||
valid_from__lte=timezone.now(),
|
||||
valid_to__gte=timezone.now(),
|
||||
)
|
||||
),
|
||||
queryset=None,
|
||||
widget=forms.Select(attrs={'id': 'id_checkout_select'}),
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Create the queryset on form instanciation to use the current time.
|
||||
self.fields['checkout'].queryset = (
|
||||
Checkout.objects.is_valid().filter(is_protected=False))
|
||||
|
||||
|
||||
class KPsulOperationForm(forms.ModelForm):
|
||||
article = forms.ModelChoiceField(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue