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
58483052
Kaydet (Commit)
58483052
authored
Agu 17, 2017
tarafından
Sebastian Sassi
Kaydeden (comit)
Tim Graham
Eyl 04, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28082 -- Made BaseDateListView pass context from get_dated_items() to subclasses.
Thanks leon-matthews for the report and fix.
üst
0d3f567a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
3 deletions
+22
-3
dates.py
django/views/generic/dates.py
+5
-3
test_dates.py
tests/generic_views/test_dates.py
+17
-0
No files found.
django/views/generic/dates.py
Dosyayı görüntüle @
58483052
...
...
@@ -297,9 +297,11 @@ class BaseDateListView(MultipleObjectMixin, DateMixin, View):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
date_list
,
self
.
object_list
,
extra_context
=
self
.
get_dated_items
()
context
=
self
.
get_context_data
(
object_list
=
self
.
object_list
,
date_list
=
self
.
date_list
)
context
.
update
(
extra_context
)
context
=
self
.
get_context_data
(
object_list
=
self
.
object_list
,
date_list
=
self
.
date_list
,
**
extra_context
)
return
self
.
render_to_response
(
context
)
def
get_dated_items
(
self
):
...
...
tests/generic_views/test_dates.py
Dosyayı görüntüle @
58483052
import
datetime
from
unittest
import
mock
from
django.core.exceptions
import
ImproperlyConfigured
from
django.test
import
TestCase
,
override_settings
,
skipUnlessDBFeature
...
...
@@ -274,6 +275,22 @@ class YearArchiveViewTests(TestDataMixin, TestCase):
res
=
self
.
client
.
get
(
'/dates/books/2011/'
)
self
.
assertEqual
(
list
(
res
.
context
[
'date_list'
]),
list
(
sorted
(
res
.
context
[
'date_list'
])))
@mock.patch
(
'django.views.generic.list.MultipleObjectMixin.get_context_data'
)
def
test_get_context_data_receives_extra_context
(
self
,
mock
):
"""
MultipleObjectMixin.get_context_data() receives the context set by
BaseYearArchiveView.get_dated_items(). This behavior is implemented in
BaseDateListView.get().
"""
BookSigning
.
objects
.
create
(
event_date
=
datetime
.
datetime
(
2008
,
4
,
2
,
12
,
0
))
with
self
.
assertRaisesMessage
(
TypeError
,
'context must be a dict rather than MagicMock.'
):
self
.
client
.
get
(
'/dates/booksignings/2008/'
)
args
,
kwargs
=
mock
.
call_args
# These are context values from get_dated_items().
self
.
assertEqual
(
kwargs
[
'year'
],
datetime
.
date
(
2008
,
1
,
1
))
self
.
assertIsNone
(
kwargs
[
'previous_year'
])
self
.
assertIsNone
(
kwargs
[
'next_year'
])
@override_settings
(
ROOT_URLCONF
=
'generic_views.urls'
)
class
MonthArchiveViewTests
(
TestDataMixin
,
TestCase
):
...
...
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