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
fc9566d4
Kaydet (Commit)
fc9566d4
authored
Nis 25, 2019
tarafından
oliver
Kaydeden (comit)
Mariusz Felisiak
Nis 25, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #30393 -- Added validation of startapp's directory option.
üst
0f22671e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
5 deletions
+28
-5
templates.py
django/core/management/templates.py
+9
-5
tests.py
tests/admin_scripts/tests.py
+19
-0
No files found.
django/core/management/templates.py
Dosyayı görüntüle @
fc9566d4
...
...
@@ -74,6 +74,8 @@ class TemplateCommand(BaseCommand):
except
OSError
as
e
:
raise
CommandError
(
e
)
else
:
if
app_or_project
==
'app'
:
self
.
validate_name
(
os
.
path
.
basename
(
target
),
'directory'
)
top_dir
=
os
.
path
.
abspath
(
path
.
expanduser
(
target
))
if
not
os
.
path
.
exists
(
top_dir
):
raise
CommandError
(
"Destination directory '
%
s' does not "
...
...
@@ -205,7 +207,7 @@ class TemplateCommand(BaseCommand):
raise
CommandError
(
"couldn't handle
%
s template
%
s."
%
(
self
.
app_or_project
,
template
))
def
validate_name
(
self
,
name
):
def
validate_name
(
self
,
name
,
name_or_dir
=
'name'
):
if
name
is
None
:
raise
CommandError
(
'you must provide {an} {app} name'
.
format
(
an
=
self
.
a_or_an
,
...
...
@@ -214,10 +216,11 @@ class TemplateCommand(BaseCommand):
# Check it's a valid directory name.
if
not
name
.
isidentifier
():
raise
CommandError
(
"'{name}' is not a valid {app}
name
. Please make sure the "
"
name
is a valid identifier."
.
format
(
"'{name}' is not a valid {app}
{type}
. Please make sure the "
"
{type}
is a valid identifier."
.
format
(
name
=
name
,
app
=
self
.
app_or_project
,
type
=
name_or_dir
,
)
)
# Check it cannot be imported.
...
...
@@ -228,11 +231,12 @@ class TemplateCommand(BaseCommand):
else
:
raise
CommandError
(
"'{name}' conflicts with the name of an existing Python "
"module and cannot be used as {an} {app}
name
. Please try "
"another
name
."
.
format
(
"module and cannot be used as {an} {app}
{type}
. Please try "
"another
{type}
."
.
format
(
name
=
name
,
an
=
self
.
a_or_an
,
app
=
self
.
app_or_project
,
type
=
name_or_dir
,
)
)
...
...
tests/admin_scripts/tests.py
Dosyayı görüntüle @
fc9566d4
...
...
@@ -2132,6 +2132,25 @@ class StartApp(AdminScriptTestCase):
)
self
.
assertFalse
(
os
.
path
.
exists
(
testproject_dir
))
def
test_invalid_target_name
(
self
):
for
bad_target
in
(
'invalid.dir_name'
,
'7invalid_dir_name'
,
'.invalid_dir_name'
):
with
self
.
subTest
(
bad_target
):
_
,
err
=
self
.
run_django_admin
([
'startapp'
,
'app'
,
bad_target
])
self
.
assertOutput
(
err
,
"CommandError: '
%
s' is not a valid app directory. Please "
"make sure the directory is a valid identifier."
%
bad_target
)
def
test_importable_target_name
(
self
):
_
,
err
=
self
.
run_django_admin
([
'startapp'
,
'app'
,
'os'
])
self
.
assertOutput
(
err
,
"CommandError: 'os' conflicts with the name of an existing Python "
"module and cannot be used as an app directory. Please try "
"another directory."
)
def
test_overlaying_app
(
self
):
self
.
run_django_admin
([
'startapp'
,
'app1'
])
out
,
err
=
self
.
run_django_admin
([
'startapp'
,
'app2'
,
'app1'
])
...
...
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