ProjectDjango/DjangoSquashMigrationSelectionDialog.py

changeset 125
d280acf98fb5
parent 121
2346aa3fffcc
child 142
ecadd7fd0963
equal deleted inserted replaced
124:5c925935cbb9 125:d280acf98fb5
22 class DjangoSquashMigrationSelectionDialog( 22 class DjangoSquashMigrationSelectionDialog(
23 QDialog, Ui_DjangoSquashMigrationSelectionDialog): 23 QDialog, Ui_DjangoSquashMigrationSelectionDialog):
24 """ 24 """
25 Class implementing a dialog to enter data needed to squash migrations. 25 Class implementing a dialog to enter data needed to squash migrations.
26 """ 26 """
27 def __init__(self, migrations, showStart, parent=None): 27 def __init__(self, migrations, django, parent=None):
28 """ 28 """
29 Constructor 29 Constructor
30 30
31 @param migrations dictionary containing the available migrations 31 @param migrations dictionary containing the available migrations
32 @type dict 32 @type dict
33 @param showStart flag indicating to show the start migrations 33 @param django reference to the Django project object
34 @type bool 34 @type Project
35 @param parent reference to the parent widget 35 @param parent reference to the parent widget
36 @type QWidget 36 @type QWidget
37 """ 37 """
38 super(DjangoSquashMigrationSelectionDialog, self).__init__(parent) 38 super(DjangoSquashMigrationSelectionDialog, self).__init__(parent)
39 self.setupUi(self) 39 self.setupUi(self)
40 40
41 self.__appliedIcon = QIcon(os.path.join( 41 self.__appliedIcon = QIcon(os.path.join(
42 os.path.dirname(__file__), "icons", "applied.png")) 42 os.path.dirname(__file__), "icons", "applied.png"))
43 43
44 self.startLabel.setEnabled(showStart) 44 self.__version = django.getDjangoVersion()
45 self.startMigrationComboBox.setEnabled(showStart) 45 self.startMigrationComboBox.setEnabled(self.__version >= (1, 9, 0))
46 self.nameEdit.setEnabled(self.__version >= (2, 0, 0))
46 47
47 self.__migrations = migrations 48 self.__migrations = migrations
48 self.applicationComboBox.addItems( 49 self.applicationComboBox.addItems(
49 [""] + sorted(self.__migrations.keys())) 50 [""] + sorted(self.__migrations.keys()))
50 self.on_applicationComboBox_activated("") 51 self.on_applicationComboBox_activated("")
102 """ 103 """
103 if self.startMigrationComboBox.isEnabled(): 104 if self.startMigrationComboBox.isEnabled():
104 startMigration = self.startMigrationComboBox.currentText() 105 startMigration = self.startMigrationComboBox.currentText()
105 else: 106 else:
106 startMigration = "" 107 startMigration = ""
108 if self.nameEdit.isEnabled():
109 name = self.nameEdit.text()
110 else:
111 name = ""
107 112
108 return ( 113 return (
109 self.applicationComboBox.currentText(), 114 self.applicationComboBox.currentText(),
110 startMigration, 115 startMigration,
111 self.endMigrationComboBox.currentText(), 116 self.endMigrationComboBox.currentText(),
112 self.noOptimizeCheckBox.isChecked(), 117 self.noOptimizeCheckBox.isChecked(),
118 name
113 ) 119 )

eric ide

mercurial