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
3f300efe
Kaydet (Commit)
3f300efe
authored
Eki 22, 2015
tarafından
Yoong Kang Lim
Kaydeden (comit)
Tim Graham
Eki 22, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #25589 -- Allowed startapp/project to create apps with Unicode characters in the name.
üst
ee66d8dd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
3 deletions
+34
-3
templates.py
django/core/management/templates.py
+7
-0
tests.py
tests/admin_scripts/tests.py
+27
-3
No files found.
django/core/management/templates.py
Dosyayı görüntüle @
3f300efe
...
@@ -208,6 +208,7 @@ class TemplateCommand(BaseCommand):
...
@@ -208,6 +208,7 @@ class TemplateCommand(BaseCommand):
raise
CommandError
(
"you must provide
%
s
%
s name"
%
(
raise
CommandError
(
"you must provide
%
s
%
s name"
%
(
"an"
if
app_or_project
==
"app"
else
"a"
,
app_or_project
))
"an"
if
app_or_project
==
"app"
else
"a"
,
app_or_project
))
# If it's not a valid directory name.
# If it's not a valid directory name.
if
six
.
PY2
:
if
not
re
.
search
(
r'^[_a-zA-Z]\w*$'
,
name
):
if
not
re
.
search
(
r'^[_a-zA-Z]\w*$'
,
name
):
# Provide a smart error message, depending on the error.
# Provide a smart error message, depending on the error.
if
not
re
.
search
(
r'^[_a-zA-Z]'
,
name
):
if
not
re
.
search
(
r'^[_a-zA-Z]'
,
name
):
...
@@ -216,6 +217,12 @@ class TemplateCommand(BaseCommand):
...
@@ -216,6 +217,12 @@ class TemplateCommand(BaseCommand):
message
=
'use only numbers, letters and underscores'
message
=
'use only numbers, letters and underscores'
raise
CommandError
(
"
%
r is not a valid
%
s name. Please
%
s."
%
raise
CommandError
(
"
%
r is not a valid
%
s name. Please
%
s."
%
(
name
,
app_or_project
,
message
))
(
name
,
app_or_project
,
message
))
else
:
if
not
name
.
isidentifier
():
raise
CommandError
(
"
%
r is not a valid
%
s name. Please make sure the name is "
"a valid identifier."
%
(
name
,
app_or_project
)
)
def
download
(
self
,
url
):
def
download
(
self
,
url
):
"""
"""
...
...
tests/admin_scripts/tests.py
Dosyayı görüntüle @
3f300efe
...
@@ -31,7 +31,7 @@ from django.test import (
...
@@ -31,7 +31,7 @@ from django.test import (
from
django.test.runner
import
DiscoverRunner
from
django.test.runner
import
DiscoverRunner
from
django.utils._os
import
npath
,
upath
from
django.utils._os
import
npath
,
upath
from
django.utils.encoding
import
force_text
from
django.utils.encoding
import
force_text
from
django.utils.six
import
PY3
,
StringIO
from
django.utils.six
import
PY
2
,
PY
3
,
StringIO
custom_templates_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
upath
(
__file__
)),
'custom_templates'
)
custom_templates_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
upath
(
__file__
)),
'custom_templates'
)
...
@@ -633,6 +633,20 @@ class DjangoAdminSettingsDirectory(AdminScriptTestCase):
...
@@ -633,6 +633,20 @@ class DjangoAdminSettingsDirectory(AdminScriptTestCase):
self
.
assertTrue
(
os
.
path
.
exists
(
app_path
))
self
.
assertTrue
(
os
.
path
.
exists
(
app_path
))
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
app_path
,
'api.py'
)))
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
app_path
,
'api.py'
)))
@unittest.skipIf
(
PY2
,
"Python 2 doesn't support Unicode package names."
)
def
test_startapp_unicode_name
(
self
):
"directory: startapp creates the correct directory with unicode characters"
args
=
[
'startapp'
,
'こんにちは'
]
app_path
=
os
.
path
.
join
(
self
.
test_dir
,
'こんにちは'
)
out
,
err
=
self
.
run_django_admin
(
args
,
'test_project.settings'
)
self
.
addCleanup
(
shutil
.
rmtree
,
app_path
)
self
.
assertNoOutput
(
err
)
self
.
assertTrue
(
os
.
path
.
exists
(
app_path
))
with
open
(
os
.
path
.
join
(
app_path
,
'apps.py'
),
'r'
)
as
f
:
content
=
f
.
read
()
self
.
assertIn
(
"class こんにちはConfig(AppConfig)"
,
content
)
self
.
assertIn
(
"name = 'こんにちは'"
,
content
)
def
test_builtin_command
(
self
):
def
test_builtin_command
(
self
):
"directory: django-admin builtin commands fail with an error when no settings provided"
"directory: django-admin builtin commands fail with an error when no settings provided"
args
=
[
'check'
,
'admin_scripts'
]
args
=
[
'check'
,
'admin_scripts'
]
...
@@ -1887,8 +1901,18 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase):
...
@@ -1887,8 +1901,18 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase):
self
.
addCleanup
(
shutil
.
rmtree
,
testproject_dir
,
True
)
self
.
addCleanup
(
shutil
.
rmtree
,
testproject_dir
,
True
)
out
,
err
=
self
.
run_django_admin
(
args
)
out
,
err
=
self
.
run_django_admin
(
args
)
self
.
assertOutput
(
err
,
"Error: '
%
s' is not a valid project name. "
if
PY2
:
"Please make sure the name begins with a letter or underscore."
%
bad_name
)
self
.
assertOutput
(
err
,
"Error: '
%
s' is not a valid project name. Please make "
"sure the name begins with a letter or underscore."
%
bad_name
)
else
:
self
.
assertOutput
(
err
,
"Error: '
%
s' is not a valid project name. Please make "
"sure the name is a valid identifier."
%
bad_name
)
self
.
assertFalse
(
os
.
path
.
exists
(
testproject_dir
))
self
.
assertFalse
(
os
.
path
.
exists
(
testproject_dir
))
def
test_simple_project_different_directory
(
self
):
def
test_simple_project_different_directory
(
self
):
...
...
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