django2.2: adapt DateTimeField in forms with the new API

This commit is contained in:
Antoine Bartuccio 2019-10-05 23:24:31 +02:00
parent 6cc234e8d3
commit 12b6f0d488
Signed by: klmp200
GPG Key ID: E7245548C53F904B
5 changed files with 21 additions and 15 deletions

View File

@ -159,13 +159,13 @@ class MailingForm(forms.Form):
class SellingsFormBase(forms.Form):
begin_date = forms.DateTimeField(
["%Y-%m-%d %H:%M:%S"],
input_formats=["%Y-%m-%d %H:%M:%S"],
label=_("Begin date"),
required=False,
widget=SelectDateTime,
)
end_date = forms.DateTimeField(
["%Y-%m-%d %H:%M:%S"],
input_formats=["%Y-%m-%d %H:%M:%S"],
label=_("End date"),
required=False,
widget=SelectDateTime,

View File

@ -74,14 +74,14 @@ class PosterForm(forms.ModelForm):
widgets = {"screens": forms.CheckboxSelectMultiple}
date_begin = forms.DateTimeField(
["%Y-%m-%d %H:%M:%S"],
input_formats=["%Y-%m-%d %H:%M:%S"],
label=_("Start date"),
widget=SelectDateTime,
required=True,
initial=timezone.now().strftime("%Y-%m-%d %H:%M:%S"),
)
date_end = forms.DateTimeField(
["%Y-%m-%d %H:%M:%S"],
input_formats=["%Y-%m-%d %H:%M:%S"],
label=_("End date"),
widget=SelectDateTime,
required=False,
@ -200,19 +200,22 @@ class NewsForm(forms.ModelForm):
}
start_date = forms.DateTimeField(
["%Y-%m-%d %H:%M:%S"],
input_formats=["%Y-%m-%d %H:%M:%S"],
label=_("Start date"),
widget=SelectDateTime,
required=False,
)
end_date = forms.DateTimeField(
["%Y-%m-%d %H:%M:%S"],
input_formats=["%Y-%m-%d %H:%M:%S"],
label=_("End date"),
widget=SelectDateTime,
required=False,
)
until = forms.DateTimeField(
["%Y-%m-%d %H:%M:%S"], label=_("Until"), widget=SelectDateTime, required=False
input_formats=["%Y-%m-%d %H:%M:%S"],
label=_("Until"),
widget=SelectDateTime,
required=False,
)
automoderation = forms.BooleanField(label=_("Automoderation"), required=False)

View File

@ -1554,13 +1554,13 @@ class CashSummaryEditView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
class CashSummaryFormBase(forms.Form):
begin_date = forms.DateTimeField(
["%Y-%m-%d %H:%M:%S"],
input_formats=["%Y-%m-%d %H:%M:%S"],
label=_("Begin date"),
required=False,
widget=SelectDateTime,
)
end_date = forms.DateTimeField(
["%Y-%m-%d %H:%M:%S"],
input_formats=["%Y-%m-%d %H:%M:%S"],
label=_("End date"),
required=False,
widget=SelectDateTime,

View File

@ -181,22 +181,25 @@ class ElectionForm(forms.ModelForm):
)
start_date = forms.DateTimeField(
["%Y-%m-%d %H:%M:%S"],
input_formats=["%Y-%m-%d %H:%M:%S"],
label=_("Start date"),
widget=SelectDateTime,
required=True,
)
end_date = forms.DateTimeField(
["%Y-%m-%d %H:%M:%S"], label=_("End date"), widget=SelectDateTime, required=True
input_formats=["%Y-%m-%d %H:%M:%S"],
label=_("End date"),
widget=SelectDateTime,
required=True,
)
start_candidature = forms.DateTimeField(
["%Y-%m-%d %H:%M:%S"],
input_formats=["%Y-%m-%d %H:%M:%S"],
label=_("Start candidature"),
widget=SelectDateTime,
required=True,
)
end_candidature = forms.DateTimeField(
["%Y-%m-%d %H:%M:%S"],
input_formats=["%Y-%m-%d %H:%M:%S"],
label=_("End candidature"),
widget=SelectDateTime,
required=True,

View File

@ -42,13 +42,13 @@ class SelectionDateForm(forms.Form):
def __init__(self, *args, **kwargs):
super(SelectionDateForm, self).__init__(*args, **kwargs)
self.fields["start_date"] = forms.DateTimeField(
["%Y-%m-%d %H:%M:%S"],
input_formats=["%Y-%m-%d %H:%M:%S"],
label=_("Start date"),
widget=SelectDateTime,
required=True,
)
self.fields["end_date"] = forms.DateTimeField(
["%Y-%m-%d %H:%M:%S"],
input_formats=["%Y-%m-%d %H:%M:%S"],
label=_("End date"),
widget=SelectDateTime,
required=True,