ProjectDjango/DjangoSquashMigrationSelectionDialog.py

changeset 169
b8f263e05c39
parent 168
c6182aab51e9
child 172
ea7980ded4f3
equal deleted inserted replaced
168:c6182aab51e9 169:b8f263e05c39
34 @param suffix icon suffix 34 @param suffix icon suffix
35 @type str 35 @type str
36 @param parent reference to the parent widget 36 @param parent reference to the parent widget
37 @type QWidget 37 @type QWidget
38 """ 38 """
39 super(DjangoSquashMigrationSelectionDialog, self).__init__(parent) 39 super().__init__(parent)
40 self.setupUi(self) 40 self.setupUi(self)
41 41
42 self.__appliedIcon = QIcon(os.path.join( 42 self.__appliedIcon = QIcon(os.path.join(
43 os.path.dirname(__file__), "icons", "applied-{0}".format(suffix) 43 os.path.dirname(__file__), "icons", "applied-{0}".format(suffix)
44 )) 44 ))
45
46 self.__version = django.getDjangoVersion()
47 self.startMigrationComboBox.setEnabled(self.__version >= (1, 9, 0))
48 self.nameEdit.setEnabled(self.__version >= (2, 0, 0))
49 45
50 self.__migrations = migrations 46 self.__migrations = migrations
51 self.applicationComboBox.addItems( 47 self.applicationComboBox.addItems(
52 [""] + sorted(self.__migrations.keys())) 48 [""] + sorted(self.__migrations.keys()))
53 self.on_applicationComboBox_activated("") 49 self.on_applicationComboBox_activated("")
101 97
102 @return tuple containing the selected app, the start migration, 98 @return tuple containing the selected app, the start migration,
103 the end migration and a flag indicating no optimization is wanted 99 the end migration and a flag indicating no optimization is wanted
104 @rtype tuple of three str and a bool 100 @rtype tuple of three str and a bool
105 """ 101 """
106 if self.startMigrationComboBox.isEnabled(): 102 startMigration = (
107 startMigration = self.startMigrationComboBox.currentText() 103 self.startMigrationComboBox.currentText()
108 else: 104 if self.startMigrationComboBox.isEnabled() else
109 startMigration = "" 105 ""
110 if self.nameEdit.isEnabled(): 106 )
111 name = self.nameEdit.text() 107 name = self.nameEdit.text() if self.nameEdit.isEnabled() else ""
112 else:
113 name = ""
114 108
115 return ( 109 return (
116 self.applicationComboBox.currentText(), 110 self.applicationComboBox.currentText(),
117 startMigration, 111 startMigration,
118 self.endMigrationComboBox.currentText(), 112 self.endMigrationComboBox.currentText(),

eric ide

mercurial