ProjectDjango/DjangoMigrationSelectionDialog.py

changeset 77
f8e92eaaba6e
parent 75
0165ce437462
child 93
cf83715ac2f7
equal deleted inserted replaced
76:230363929c49 77:f8e92eaaba6e
22 class DjangoMigrationSelectionDialog(QDialog, 22 class DjangoMigrationSelectionDialog(QDialog,
23 Ui_DjangoMigrationSelectionDialog): 23 Ui_DjangoMigrationSelectionDialog):
24 """ 24 """
25 Class implementing a dialog to select an application and migration. 25 Class implementing a dialog to select an application and migration.
26 """ 26 """
27 def __init__(self, migrations, parent=None): 27 def __init__(self, migrations, migrationRequired=False, 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 migrationRequired flag indicating that a migration must be
34 selected
35 @type bool
33 @param parent reference to the parent widget 36 @param parent reference to the parent widget
34 @type QWidget 37 @type QWidget
35 """ 38 """
36 super(DjangoMigrationSelectionDialog, self).__init__(parent) 39 super(DjangoMigrationSelectionDialog, self).__init__(parent)
37 self.setupUi(self) 40 self.setupUi(self)
38 41
39 self.__appliedIcon = QIcon(os.path.join( 42 self.__appliedIcon = QIcon(os.path.join(
40 os.path.dirname(__file__), "icons", "applied.png")) 43 os.path.dirname(__file__), "icons", "applied.png"))
44
45 self.__migrationRequired = migrationRequired
41 46
42 self.__migrations = migrations 47 self.__migrations = migrations
43 self.applicationComboBox.addItems(sorted(self.__migrations.keys())) 48 self.applicationComboBox.addItems(sorted(self.__migrations.keys()))
44 self.on_applicationComboBox_activated( 49 self.on_applicationComboBox_activated(
45 self.applicationComboBox.currentText()) 50 self.applicationComboBox.currentText())
54 59
55 @param app name of the selected application 60 @param app name of the selected application
56 @type str 61 @type str
57 """ 62 """
58 self.migrationsComboBox.clear() 63 self.migrationsComboBox.clear()
59 self.migrationsComboBox.addItem("") 64 if not self.__migrationRequired:
65 self.migrationsComboBox.addItem("")
60 for applied, migration in self.__migrations[app]: 66 for applied, migration in self.__migrations[app]:
61 if applied: 67 if applied:
62 self.migrationsComboBox.addItem(self.__appliedIcon, migration) 68 self.migrationsComboBox.addItem(self.__appliedIcon, migration)
63 else: 69 else:
64 self.migrationsComboBox.addItem(migration) 70 self.migrationsComboBox.addItem(migration)

eric ide

mercurial