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): class SellingsFormBase(forms.Form):
begin_date = forms.DateTimeField( begin_date = forms.DateTimeField(
["%Y-%m-%d %H:%M:%S"], input_formats=["%Y-%m-%d %H:%M:%S"],
label=_("Begin date"), label=_("Begin date"),
required=False, required=False,
widget=SelectDateTime, widget=SelectDateTime,
) )
end_date = forms.DateTimeField( end_date = forms.DateTimeField(
["%Y-%m-%d %H:%M:%S"], input_formats=["%Y-%m-%d %H:%M:%S"],
label=_("End date"), label=_("End date"),
required=False, required=False,
widget=SelectDateTime, widget=SelectDateTime,

View File

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

View File

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

View File

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

View File

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