Author: carljm
Date: 2012-01-04 15:55:34 -0800 (Wed, 04 Jan 2012)
New Revision: 17340

Modified:
   django/trunk/django/core/management/templates.py
   django/trunk/docs/ref/django-admin.txt
   django/trunk/tests/regressiontests/admin_scripts/tests.py
Log:
Fixed #17503 -- A destination directory passed to startproject or startapp as 
optional second argument is now reused as the project/app directory, rather 
than a new project/app directory created within it. Refs #17042.

Modified: django/trunk/django/core/management/templates.py
===================================================================
--- django/trunk/django/core/management/templates.py    2012-01-04 18:35:45 UTC 
(rev 17339)
+++ django/trunk/django/core/management/templates.py    2012-01-04 23:55:34 UTC 
(rev 17340)
@@ -73,15 +73,14 @@
 
         # if some directory is given, make sure it's nicely expanded
         if target is None:
-            target = os.getcwd()
+            top_dir = path.join(os.getcwd(), name)
+            try:
+                os.makedirs(top_dir)
+            except OSError, e:
+                raise CommandError(e)
         else:
-            target = path.expanduser(target)
+            top_dir = path.expanduser(target)
 
-        top_dir = path.join(target, name)
-        try:
-            os.makedirs(top_dir)
-        except OSError, e:
-            raise CommandError(e)
 
         extensions = tuple(
             handle_extensions(options.get('extensions'), ignored=()))

Modified: django/trunk/docs/ref/django-admin.txt
===================================================================
--- django/trunk/docs/ref/django-admin.txt      2012-01-04 18:35:45 UTC (rev 
17339)
+++ django/trunk/docs/ref/django-admin.txt      2012-01-04 23:55:34 UTC (rev 
17340)
@@ -922,13 +922,13 @@
 name is given, the app directory will be created in the current working
 directory.
 
-If the optional destination is provided, Django will create the new project
-directory in that directory. You can use '.' to denote the current working
-directory.
+If the optional destination is provided, Django will use that existing
+directory rather than creating a new one. You can use '.' to denote the current
+working directory.
 
 For example::
 
-    django-admin.py startapp myapp /Users/jezdez/Code
+    django-admin.py startapp myapp /Users/jezdez/Code/myapp
 
 .. versionadded:: 1.4
 .. django-admin-option:: --template
@@ -984,20 +984,20 @@
 .. versionchanged:: 1.4
 
 By default, the new directory contains ``manage.py`` and a project package
-(containing ``settings.py`` file and other project template files).
-See the `template source`_ for details.
+(containing a ``settings.py`` and other files).  See the `template source`_ for
+details.
 
 If only the project name is given, both the project directory and project
 package will be named ``<projectname>`` and the project directory
 will be created in the current working directory.
 
-If the optional destination is provided, Django will create the new project
-directory in that directory. You can use '.' to denote the current working
-directory.
+If the optional destination is provided, Django will use that existing
+directory as the project directory, and create ``manage.py`` and the project
+package within it. You can use '.' to denote the current working directory.
 
 For example::
 
-    django-admin.py startproject myproject /Users/jezdez/Code
+    django-admin.py startproject myproject /Users/jezdez/Code/myproject_repo
 
 .. versionadded:: 1.4
 

Modified: django/trunk/tests/regressiontests/admin_scripts/tests.py
===================================================================
--- django/trunk/tests/regressiontests/admin_scripts/tests.py   2012-01-04 
18:35:45 UTC (rev 17339)
+++ django/trunk/tests/regressiontests/admin_scripts/tests.py   2012-01-04 
23:55:34 UTC (rev 17340)
@@ -1404,17 +1404,17 @@
         "Make sure the startproject management command creates a project in a 
specific directory"
         args = ['startproject', 'testproject', 'othertestproject']
         testproject_dir = os.path.join(test_dir, 'othertestproject')
+        os.mkdir(testproject_dir)
 
         out, err = self.run_django_admin(args)
         self.addCleanup(shutil.rmtree, testproject_dir)
         self.assertNoOutput(err)
-        self.assertTrue(os.path.isdir(os.path.join(testproject_dir, 
'testproject')))
-        self.assertTrue(os.path.exists(os.path.join(testproject_dir, 
'testproject', 'manage.py')))
+        self.assertTrue(os.path.exists(os.path.join(testproject_dir, 
'manage.py')))
 
         # running again..
         out, err = self.run_django_admin(args)
         self.assertNoOutput(out)
-        self.assertOutput(err, "File exists")
+        self.assertOutput(err, "already exists")
 
     def test_custom_project_template(self):
         "Make sure the startproject management command is able to use a 
different project template"
@@ -1452,6 +1452,19 @@
         self.assertTrue(os.path.isdir(testproject_dir))
         self.assertTrue(os.path.exists(os.path.join(testproject_dir, 
'run.py')))
 
+    def 
test_custom_project_template_from_tarball_to_alternative_location(self):
+        "Startproject can use a project template from a tarball and create it 
in a specified location"
+        template_path = os.path.join(test_dir, 'admin_scripts', 
'custom_templates', 'project_template.tgz')
+        args = ['startproject', '--template', template_path, 
'tarballtestproject', 'altlocation']
+        testproject_dir = os.path.join(test_dir, 'altlocation')
+        os.mkdir(testproject_dir)
+
+        out, err = self.run_django_admin(args)
+        self.addCleanup(shutil.rmtree, testproject_dir)
+        self.assertNoOutput(err)
+        self.assertTrue(os.path.isdir(testproject_dir))
+        self.assertTrue(os.path.exists(os.path.join(testproject_dir, 
'run.py')))
+
     def test_custom_project_template_from_tarball_by_url(self):
         "Make sure the startproject management command is able to use a 
different project template from a tarball via a url"
         template_url = 
'%s/admin_scripts/custom_templates/project_template.tgz' % self.live_server_url

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to