745 )) |
745 )) |
746 self.makeMigrationsAct.triggered.connect(self.__makeMigrations) |
746 self.makeMigrationsAct.triggered.connect(self.__makeMigrations) |
747 self.actions.append(self.makeMigrationsAct) |
747 self.actions.append(self.makeMigrationsAct) |
748 |
748 |
749 # TODO: squashmigrations |
749 # TODO: squashmigrations |
|
750 self.squashMigrationsAct = E5Action( |
|
751 self.tr('Squash Migrations'), |
|
752 self.tr('S&quash Migrations'), |
|
753 0, 0, |
|
754 self, 'django_migration_squash') |
|
755 self.squashMigrationsAct.setStatusTip(self.tr( |
|
756 'Squash migrations of an application of the project')) |
|
757 self.squashMigrationsAct.setWhatsThis(self.tr( |
|
758 """<b>Squash Migrations</b>""" |
|
759 """<p>This squashes migrations of an application of the""" |
|
760 """ Django project.</p>""" |
|
761 )) |
|
762 self.squashMigrationsAct.triggered.connect(self.__squashMigrations) |
|
763 self.actions.append(self.squashMigrationsAct) |
750 |
764 |
751 # TODO: sqlmigrate |
765 # TODO: sqlmigrate |
752 |
766 |
753 def initMenu(self): |
767 def initMenu(self): |
754 """ |
768 """ |
859 menu.addAction(self.migrateAllAct) |
873 menu.addAction(self.migrateAllAct) |
860 menu.addAction(self.migrateSelectedAct) |
874 menu.addAction(self.migrateSelectedAct) |
861 menu.addAction(self.unmigrateAct) |
875 menu.addAction(self.unmigrateAct) |
862 menu.addSeparator() |
876 menu.addSeparator() |
863 menu.addAction(self.makeMigrationsAct) |
877 menu.addAction(self.makeMigrationsAct) |
|
878 menu.addSeparator() |
|
879 menu.addAction(self.squashMigrationsAct) |
864 |
880 |
865 self.__menus["migrations"] = menu |
881 self.__menus["migrations"] = menu |
866 |
882 |
867 return menu |
883 return menu |
868 |
884 |
1331 os.path.join(virtualEnv, "Scripts", pythonExe), |
1347 os.path.join(virtualEnv, "Scripts", pythonExe), |
1332 os.path.join(virtualEnv, "bin", pythonExe), |
1348 os.path.join(virtualEnv, "bin", pythonExe), |
1333 os.path.join(virtualEnv, pythonExe) |
1349 os.path.join(virtualEnv, pythonExe) |
1334 ]: |
1350 ]: |
1335 if os.path.exists(python): |
1351 if os.path.exists(python): |
1336 break |
1352 break |
1337 else: |
1353 else: |
1338 python = "" |
1354 python = "" |
1339 |
1355 |
1340 if python: |
1356 if python: |
1341 break |
1357 break |
1355 os.path.join(virtualEnv, "bin", pythonExe), |
1371 os.path.join(virtualEnv, "bin", pythonExe), |
1356 # omit the version character |
1372 # omit the version character |
1357 os.path.join(virtualEnv, "bin", pythonExe)[:-1], |
1373 os.path.join(virtualEnv, "bin", pythonExe)[:-1], |
1358 ]: |
1374 ]: |
1359 if os.path.exists(python): |
1375 if os.path.exists(python): |
1360 break |
1376 break |
1361 else: |
1377 else: |
1362 python = "" |
1378 python = "" |
1363 |
1379 |
1364 if python: |
1380 if python: |
1365 break |
1381 break |
2165 self.__migrationsPlanDialog.show() |
2181 self.__migrationsPlanDialog.show() |
2166 self.__migrationsPlanDialog.start(self.__getPythonExecutable(), path) |
2182 self.__migrationsPlanDialog.start(self.__getPythonExecutable(), path) |
2167 |
2183 |
2168 def __applyAllMigrations(self): |
2184 def __applyAllMigrations(self): |
2169 """ |
2185 """ |
2170 Public slot to apply all migrations. |
2186 Private slot to apply all migrations. |
2171 """ |
2187 """ |
2172 self.applyMigrations() |
2188 self.applyMigrations() |
2173 |
2189 |
2174 def __applySelectedMigrations(self): |
2190 def __applySelectedMigrations(self): |
2175 """ |
2191 """ |
2176 Public slot to apply selected migrations of a selected app. |
2192 Private slot to apply selected migrations of a selected app. |
2177 """ |
2193 """ |
2178 migrations = self.__getMigrations() |
2194 migrations = self.__getMigrations() |
2179 if not migrations: |
2195 if not migrations: |
2180 E5MessageBox.information( |
2196 E5MessageBox.information( |
2181 None, |
2197 None, |
2329 args.append(migration.replace(" ", "_")) |
2345 args.append(migration.replace(" ", "_")) |
2330 if dryRun: |
2346 if dryRun: |
2331 args.append("--dry-run") |
2347 args.append("--dry-run") |
2332 if apps: |
2348 if apps: |
2333 args += apps |
2349 args += apps |
|
2350 |
|
2351 dia = DjangoDialog(title) |
|
2352 res = dia.startProcess(args, path) |
|
2353 if res: |
|
2354 dia.exec_() |
|
2355 |
|
2356 def __squashMigrations(self): |
|
2357 """ |
|
2358 Private slot to squash migrations. |
|
2359 """ |
|
2360 migrations = self.__getMigrations() |
|
2361 if not migrations: |
|
2362 E5MessageBox.information( |
|
2363 None, |
|
2364 self.tr("Squash Migrations"), |
|
2365 self.tr("""No migrations available.""")) |
|
2366 return |
|
2367 |
|
2368 from .DjangoSquashMigrationSelectionDialog import \ |
|
2369 DjangoSquashMigrationSelectionDialog |
|
2370 dlg = DjangoSquashMigrationSelectionDialog( |
|
2371 migrations, self.getDjangoVersion() >= (1, 9, 0)) |
|
2372 if dlg.exec_() == QDialog.Accepted: |
|
2373 app, start, end, noOptimize = dlg.getData() |
|
2374 |
|
2375 title = self.tr("Squash Migrations") |
|
2376 |
|
2377 try: |
|
2378 path = self.__sitePath() |
|
2379 except DjangoNoSiteSelectedException: |
|
2380 return |
|
2381 |
|
2382 args = [] |
|
2383 args.append(self.__getPythonExecutable()) |
|
2384 args.append("manage.py") |
|
2385 args.append("squashmigrations") |
|
2386 args.append("--noinput") |
|
2387 if noOptimize: |
|
2388 args.append("--no-optimize") |
|
2389 args.append(app) |
|
2390 if start: |
|
2391 args.append(start) |
|
2392 args.append(end) |
2334 |
2393 |
2335 dia = DjangoDialog(title) |
2394 dia = DjangoDialog(title) |
2336 res = dia.startProcess(args, path) |
2395 res = dia.startProcess(args, path) |
2337 if res: |
2396 if res: |
2338 dia.exec_() |
2397 dia.exec_() |
2589 args.append("testserver") |
2648 args.append("testserver") |
2590 if self.__plugin.getPreferences("UseIPv6"): |
2649 if self.__plugin.getPreferences("UseIPv6"): |
2591 args.append("--ipv6") |
2650 args.append("--ipv6") |
2592 addr = self.__plugin.getPreferences("ServerAddress") |
2651 addr = self.__plugin.getPreferences("ServerAddress") |
2593 if addr: |
2652 if addr: |
2594 args.append("--addrport=%s" % addr) |
2653 args.append("--addrport={0}".format(addr)) |
2595 args += fixtures |
2654 args += fixtures |
2596 |
2655 |
2597 try: |
2656 try: |
2598 if Utilities.isWindowsPlatform(): |
2657 if Utilities.isWindowsPlatform(): |
2599 serverProcStarted, pid = QProcess.startDetached( |
2658 serverProcStarted, pid = QProcess.startDetached( |