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
23142eea
Kaydet (Commit)
23142eea
authored
Nis 02, 2017
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #18394 -- Added error for invalid JavaScriptCatalog packages
Thanks Tim Graham for the review.
üst
41e02ab3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
2 deletions
+22
-2
i18n.py
django/views/i18n.py
+5
-0
2.0.txt
docs/releases/2.0.txt
+4
-0
test_i18n.py
tests/view_tests/tests/test_i18n.py
+13
-2
No files found.
django/views/i18n.py
Dosyayı görüntüle @
23142eea
...
...
@@ -232,6 +232,11 @@ class JavaScriptCatalog(View):
def
get_paths
(
self
,
packages
):
allowable_packages
=
{
app_config
.
name
:
app_config
for
app_config
in
apps
.
get_app_configs
()}
app_configs
=
[
allowable_packages
[
p
]
for
p
in
packages
if
p
in
allowable_packages
]
if
len
(
app_configs
)
<
len
(
packages
):
excluded
=
[
p
for
p
in
packages
if
p
not
in
allowable_packages
]
raise
ValueError
(
'Invalid package(s) provided to JavaScriptCatalog:
%
s'
%
','
.
join
(
excluded
)
)
# paths of requested packages
return
[
os
.
path
.
join
(
app
.
path
,
'locale'
)
for
app
in
app_configs
]
...
...
docs/releases/2.0.txt
Dosyayı görüntüle @
23142eea
...
...
@@ -420,6 +420,10 @@ Miscellaneous
Book.objects.iterator(chunk_size=100)
* Providing unknown package names in the ``packages`` argument of the
:class:`~django.views.i18n.JavaScriptCatalog` view now raises ``ValueError``
instead of passing silently.
.. _deprecated-features-2.0:
Features deprecated in 2.0
...
...
tests/view_tests/tests/test_i18n.py
Dosyayı görüntüle @
23142eea
...
...
@@ -4,14 +4,15 @@ from os import path
from
django.conf
import
settings
from
django.test
import
(
SimpleTestCase
,
TestCase
,
modify_settings
,
override_settings
,
RequestFactory
,
SimpleTestCase
,
TestCase
,
modify_settings
,
override_settings
,
)
from
django.test.selenium
import
SeleniumTestCase
from
django.urls
import
reverse
from
django.utils.translation
import
(
LANGUAGE_SESSION_KEY
,
get_language
,
override
,
)
from
django.views.i18n
import
get_formats
from
django.views.i18n
import
JavaScriptCatalog
,
get_formats
from
..urls
import
locale_dir
...
...
@@ -397,6 +398,16 @@ class I18NViewTests(SimpleTestCase):
response
=
self
.
client
.
get
(
'/jsi18n/'
)
self
.
assertContains
(
response
,
'este texto de app3 debe ser traducido'
)
def
test_i18n_unknown_package_error
(
self
):
view
=
JavaScriptCatalog
.
as_view
()
request
=
RequestFactory
()
.
get
(
'/'
)
msg
=
'Invalid package(s) provided to JavaScriptCatalog: unknown_package'
with
self
.
assertRaisesMessage
(
ValueError
,
msg
):
view
(
request
,
packages
=
'unknown_package'
)
msg
+=
',unknown_package2'
with
self
.
assertRaisesMessage
(
ValueError
,
msg
):
view
(
request
,
packages
=
'unknown_package+unknown_package2'
)
@override_settings
(
ROOT_URLCONF
=
'view_tests.urls'
)
class
I18nSeleniumTests
(
SeleniumTestCase
):
...
...
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