Mon, 19 Dec 2016 19:26:40 +0100
Added some forgotten files.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ProjectDjango/DjangoMakeMigrationsDialog.py Mon Dec 19 19:26:40 2016 +0100 @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2016 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing a dialog to enter the data needed to make migrations. +""" + +from __future__ import unicode_literals + +from PyQt5.QtWidgets import QDialog + +from .Ui_DjangoMakeMigrationsDialog import Ui_DjangoMakeMigrationsDialog + + +class DjangoMakeMigrationsDialog(QDialog, Ui_DjangoMakeMigrationsDialog): + """ + Class implementing a dialog to enter the data needed to make migrations. + """ + def __init__(self, recentApps, parent=None): + """ + Constructor + + @param parent reference to the parent widget + @type QWidget + """ + super(DjangoMakeMigrationsDialog, self).__init__(parent) + self.setupUi(self) + + self.applicationsComboBox.addItems(recentApps) + + def getData(self): + """ + Public method to get the data for the migration. + + @return tuple containing the application names, a migration name + and the dry-run flag + @rtype tuple of two str and a bool + """ + return ( + self.applicationsComboBox.currentText(), + self.nameEdit.text(), + self.dryrunCheckBox.isChecked(), + )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ProjectDjango/DjangoMakeMigrationsDialog.ui Mon Dec 19 19:26:40 2016 +0100 @@ -0,0 +1,127 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>DjangoMakeMigrationsDialog</class> + <widget class="QDialog" name="DjangoMakeMigrationsDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>500</width> + <height>140</height> + </rect> + </property> + <property name="windowTitle"> + <string>Make Migrations</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Applications:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="applicationsComboBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Enter the list of applications separated by spaces.</string> + </property> + <property name="editable"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Name:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="E5ClearableLineEdit" name="nameEdit"> + <property name="toolTip"> + <string>Enter a name for the migration</string> + </property> + </widget> + </item> + <item row="2" column="0" colspan="2"> + <widget class="QCheckBox" name="dryrunCheckBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Select to perform a dry-run</string> + </property> + <property name="text"> + <string>Dry-Run only</string> + </property> + </widget> + </item> + <item row="3" column="0" colspan="2"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>E5ClearableLineEdit</class> + <extends>QLineEdit</extends> + <header>E5Gui/E5LineEdit.h</header> + </customwidget> + </customwidgets> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>DjangoMakeMigrationsDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>DjangoMakeMigrationsDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ProjectDjango/DjangoMigrationSelectionDialog.py Mon Dec 19 19:26:40 2016 +0100 @@ -0,0 +1,80 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2016 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing a dialog to select an application and migration. +""" + +from __future__ import unicode_literals +try: + str = unicode # __IGNORE_WARNING__ +except NameError: + pass + +import os + +from PyQt5.QtCore import pyqtSlot +from PyQt5.QtGui import QIcon +from PyQt5.QtWidgets import QDialog + +from .Ui_DjangoMigrationSelectionDialog import \ + Ui_DjangoMigrationSelectionDialog + + +class DjangoMigrationSelectionDialog(QDialog, + Ui_DjangoMigrationSelectionDialog): + """ + Class implementing a dialog to select an application and migration. + """ + def __init__(self, migrations, parent=None): + """ + Constructor + + @param pythonExecutable Python executable to be used + @type str + @param sitePath path of the site + @type str + @param parent reference to the parent widget + @type QWidget + """ + super(DjangoMigrationSelectionDialog, self).__init__(parent) + self.setupUi(self) + + self.__appliedIcon = QIcon(os.path.join( + os.path.dirname(__file__), "icons", "applied.png")) + + self.__migrations = migrations + self.applicationComboBox.addItems(sorted(self.__migrations.keys())) + self.on_applicationComboBox_activated( + self.applicationComboBox.currentText()) + + msh = self.minimumSizeHint() + self.resize(max(self.width(), msh.width()), msh.height()) + + @pyqtSlot(str) + def on_applicationComboBox_activated(self, app): + """ + Private slot to update the migrations combo box. + + @param app name of the selected application + @type str + """ + self.migrationsComboBox.clear() + self.migrationsComboBox.addItem("") + for applied, migration in self.__migrations[app]: + if applied: + self.migrationsComboBox.addItem(self.__appliedIcon, migration) + else: + self.migrationsComboBox.addItem(migration) + + def getData(self): + """ + Public method to get the selected data. + + @return tuple containing the selected application name and migration + @rtype tuple of two str + """ + return (self.applicationComboBox.currentText(), + self.migrationsComboBox.currentText())
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ProjectDjango/DjangoMigrationSelectionDialog.ui Mon Dec 19 19:26:40 2016 +0100 @@ -0,0 +1,107 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>DjangoMigrationSelectionDialog</class> + <widget class="QDialog" name="DjangoMigrationSelectionDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>561</width> + <height>110</height> + </rect> + </property> + <property name="windowTitle"> + <string>Select Migration</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="1"> + <widget class="QComboBox" name="applicationComboBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Select the application</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="migrationsComboBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Select a migration</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Migration:</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Application:</string> + </property> + </widget> + </item> + <item row="2" column="0" colspan="2"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>DjangoMigrationSelectionDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>DjangoMigrationSelectionDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui>