Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
0034e9af
Kaydet (Commit)
0034e9af
authored
Ock 13, 2017
tarafından
Mariusz Felisiak
Kaydeden (comit)
Tim Graham
Şub 07, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #5851 -- Allowed specifying different HTML attrs for SplitDateTimeWidget subwidgets.
Thanks Tim Graham and Nick Pope for review.
üst
3a148f95
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
9 deletions
+52
-9
widgets.py
django/forms/widgets.py
+12
-6
widgets.txt
docs/ref/forms/widgets.txt
+11
-1
2.0.txt
docs/releases/2.0.txt
+5
-2
test_splitdatetimewidget.py
tests/forms_tests/widget_tests/test_splitdatetimewidget.py
+12
-0
test_splithiddendatetimewidget.py
...orms_tests/widget_tests/test_splithiddendatetimewidget.py
+12
-0
No files found.
django/forms/widgets.py
Dosyayı görüntüle @
0034e9af
...
...
@@ -855,12 +855,18 @@ class SplitDateTimeWidget(MultiWidget):
supports_microseconds
=
False
template_name
=
'django/forms/widgets/splitdatetime.html'
def
__init__
(
self
,
attrs
=
None
,
date_format
=
None
,
time_format
=
None
):
def
__init__
(
self
,
attrs
=
None
,
date_format
=
None
,
time_format
=
None
,
date_attrs
=
None
,
time_attrs
=
None
):
widgets
=
(
DateInput
(
attrs
=
attrs
,
format
=
date_format
),
TimeInput
(
attrs
=
attrs
,
format
=
time_format
),
DateInput
(
attrs
=
attrs
if
date_attrs
is
None
else
date_attrs
,
format
=
date_format
,
),
TimeInput
(
attrs
=
attrs
if
time_attrs
is
None
else
time_attrs
,
format
=
time_format
,
),
)
super
()
.
__init__
(
widgets
,
attrs
)
super
()
.
__init__
(
widgets
)
def
decompress
(
self
,
value
):
if
value
:
...
...
@@ -875,8 +881,8 @@ class SplitHiddenDateTimeWidget(SplitDateTimeWidget):
"""
template_name
=
'django/forms/widgets/splithiddendatetime.html'
def
__init__
(
self
,
attrs
=
None
,
date_format
=
None
,
time_format
=
None
):
super
()
.
__init__
(
attrs
,
date_format
,
time_format
)
def
__init__
(
self
,
attrs
=
None
,
date_format
=
None
,
time_format
=
None
,
date_attrs
=
None
,
time_attrs
=
None
):
super
()
.
__init__
(
attrs
,
date_format
,
time_format
,
date_attrs
,
time_attrs
)
for
widget
in
self
.
widgets
:
widget
.
input_type
=
'hidden'
...
...
docs/ref/forms/widgets.txt
Dosyayı görüntüle @
0034e9af
...
...
@@ -840,7 +840,7 @@ Composite widgets
for the date, and :class:`TimeInput` for the time. Must be used with
:class:`SplitDateTimeField` rather than :class:`DateTimeField`.
``SplitDateTimeWidget`` has
two optional attribute
s:
``SplitDateTimeWidget`` has
several optional argument
s:
.. attribute:: SplitDateTimeWidget.date_format
...
...
@@ -850,6 +850,16 @@ Composite widgets
Similar to :attr:`TimeInput.format`
.. attribute:: SplitDateTimeWidget.date_attrs
.. attribute:: SplitDateTimeWidget.time_attrs
.. versionadded:: 2.0
Similar to :attr:`Widget.attrs`. A dictionary containing HTML
attributes to be set on the rendered :class:`DateInput` and
:class:`TimeInput` widgets, respectively. If these attributes aren't
set, :attr:`Widget.attrs` is used instead.
``SplitHiddenDateTimeWidget``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
...
docs/releases/2.0.txt
Dosyayı görüntüle @
0034e9af
...
...
@@ -136,11 +136,14 @@ File Uploads
* ...
Forms
~~~~~
* ...
* The new ``date_attrs`` and ``time_attrs`` arguments for
:class:`~django.forms.SplitDateTimeWidget` and
:class:`~django.forms.SplitHiddenDateTimeWidget` allow specifying different
HTML attributes for the ``DateInput`` and ``TimeInput`` (or hidden)
subwidgets.
Generic Views
~~~~~~~~~~~~~
...
...
tests/forms_tests/widget_tests/test_splitdatetimewidget.py
Dosyayı görüntüle @
0034e9af
...
...
@@ -37,6 +37,18 @@ class SplitDateTimeWidgetTest(WidgetTest):
'<input type="text" class="pretty" value="07:30:00" name="date_1" />'
))
def
test_constructor_different_attrs
(
self
):
html
=
(
'<input type="text" class="foo" value="2006-01-10" name="date_0" />'
'<input type="text" class="bar" value="07:30:00" name="date_1" />'
)
widget
=
SplitDateTimeWidget
(
date_attrs
=
{
'class'
:
'foo'
},
time_attrs
=
{
'class'
:
'bar'
})
self
.
check_html
(
widget
,
'date'
,
datetime
(
2006
,
1
,
10
,
7
,
30
),
html
=
html
)
widget
=
SplitDateTimeWidget
(
date_attrs
=
{
'class'
:
'foo'
},
attrs
=
{
'class'
:
'bar'
})
self
.
check_html
(
widget
,
'date'
,
datetime
(
2006
,
1
,
10
,
7
,
30
),
html
=
html
)
widget
=
SplitDateTimeWidget
(
time_attrs
=
{
'class'
:
'bar'
},
attrs
=
{
'class'
:
'foo'
})
self
.
check_html
(
widget
,
'date'
,
datetime
(
2006
,
1
,
10
,
7
,
30
),
html
=
html
)
def
test_formatting
(
self
):
"""
Use 'date_format' and 'time_format' to change the way a value is
...
...
tests/forms_tests/widget_tests/test_splithiddendatetimewidget.py
Dosyayı görüntüle @
0034e9af
...
...
@@ -40,3 +40,15 @@ class SplitHiddenDateTimeWidgetTest(WidgetTest):
<input type="hidden" name="date_1" value="12:51:00" />
"""
))
def
test_constructor_different_attrs
(
self
):
html
=
(
'<input type="hidden" class="foo" value="2006-01-10" name="date_0" />'
'<input type="hidden" class="bar" value="07:30:00" name="date_1" />'
)
widget
=
SplitHiddenDateTimeWidget
(
date_attrs
=
{
'class'
:
'foo'
},
time_attrs
=
{
'class'
:
'bar'
})
self
.
check_html
(
widget
,
'date'
,
datetime
(
2006
,
1
,
10
,
7
,
30
),
html
=
html
)
widget
=
SplitHiddenDateTimeWidget
(
date_attrs
=
{
'class'
:
'foo'
},
attrs
=
{
'class'
:
'bar'
})
self
.
check_html
(
widget
,
'date'
,
datetime
(
2006
,
1
,
10
,
7
,
30
),
html
=
html
)
widget
=
SplitHiddenDateTimeWidget
(
time_attrs
=
{
'class'
:
'bar'
},
attrs
=
{
'class'
:
'foo'
})
self
.
check_html
(
widget
,
'date'
,
datetime
(
2006
,
1
,
10
,
7
,
30
),
html
=
html
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment