ProjectDjango/DjangoMigrationsListDialog.py

changeset 125
d280acf98fb5
parent 121
2346aa3fffcc
child 142
ecadd7fd0963
--- a/ProjectDjango/DjangoMigrationsListDialog.py	Sat Jan 27 11:46:33 2018 +0100
+++ b/ProjectDjango/DjangoMigrationsListDialog.py	Sat Mar 24 19:11:39 2018 +0100
@@ -136,7 +136,7 @@
         if self.__mode == DjangoMigrationsListDialog.MigrationsListMode:
             self.migrationsList.header().setStretchLastSection(True)
     
-    def start(self, pythonExecutable, sitePath):
+    def start(self, pythonExecutable, sitePath, databaseName):
         """
         Public slot used to start the process.
         
@@ -144,7 +144,10 @@
         @type str
         @param sitePath path of the site
         @type str
-        @return flag indicating a successful start of the process (boolean)
+        @param databaseName name of the database to be used
+        @type str
+        @return flag indicating a successful start of the process
+        @rtype bool
         """
         self.__pyExe = pythonExecutable
         self.__sitePath = sitePath
@@ -166,7 +169,8 @@
             args.append("--plan")
             args.append("--verbosity")
             args.append("2")
-        # TODO: add support for --database DATABASE for Django 1.9.0+
+        if databaseName:
+            args.append("--database={0}".format(databaseName))
         
         self.proc.start(pythonExecutable, args)
         procStarted = self.proc.waitForStarted()
@@ -374,13 +378,19 @@
                 apps.append(itm.text(0))
         
         if apps:
-            migration, ok = QInputDialog.getText(
-                self,
-                self.tr("Make Migrations"),
-                self.tr("Enter a name for the migrations (leave empty to"
-                        " use system supplied name):"),
-                QLineEdit.Normal)
+            if self.__django.getDjangoVersion() >= (1, 8, 0):
+                migration, ok = QInputDialog.getText(
+                    self,
+                    self.tr("Make Migrations"),
+                    self.tr("Enter a name for the migrations (leave empty to"
+                            " use system supplied name):"),
+                    QLineEdit.Normal)
+            else:
+                migration = ""
+                ok = True
+            
             if ok:
-                self.__django.makeMigrations(apps, migration, dryRun, empty)
+                self.__django.makeMigrations(apps, migration, dryRun, empty,
+                                             True)
             
             self.on_refreshButton_clicked()

eric ide

mercurial