ProjectDjango/DjangoLoaddataDataDialog.py

changeset 169
b8f263e05c39
parent 168
c6182aab51e9
child 172
ea7980ded4f3
equal deleted inserted replaced
168:c6182aab51e9 169:b8f263e05c39
4 # 4 #
5 5
6 """ 6 """
7 Module implementing a dialog to enter the data for the 'loaddata' command. 7 Module implementing a dialog to enter the data for the 'loaddata' command.
8 """ 8 """
9
10 import contextlib
9 11
10 from PyQt5.QtCore import pyqtSlot 12 from PyQt5.QtCore import pyqtSlot
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox 13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
12 14
13 from E5Gui import E5FileDialog 15 from E5Gui import E5FileDialog
27 Constructor 29 Constructor
28 30
29 @param project reference to the Django project object 31 @param project reference to the Django project object
30 @param parent reference to the parent widget (QWidget) 32 @param parent reference to the parent widget (QWidget)
31 """ 33 """
32 super(DjangoLoaddataDataDialog, self).__init__(parent) 34 super().__init__(parent)
33 self.setupUi(self) 35 self.setupUi(self)
34 36
35 self.fixtureFileButton.setIcon(UI.PixmapCache.getIcon("open")) 37 self.fixtureFileButton.setIcon(UI.PixmapCache.getIcon("open"))
36 38
37 self.__project = project 39 self.__project = project
38
39 if project.getDjangoVersion() < (1, 11, 0):
40 self.excludeBox.setEnabled(False)
41 40
42 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) 41 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
43 42
44 msh = self.minimumSizeHint() 43 msh = self.minimumSizeHint()
45 self.resize(max(self.width(), msh.width()), msh.height()) 44 self.resize(max(self.width(), msh.width()), msh.height())
57 def on_fixtureFileButton_clicked(self): 56 def on_fixtureFileButton_clicked(self):
58 """ 57 """
59 Private slot to select a fixture file via a file selection dialog. 58 Private slot to select a fixture file via a file selection dialog.
60 """ 59 """
61 fileFilters = self.tr("JSON Files (*.json);;XML Files (*.xml);;") 60 fileFilters = self.tr("JSON Files (*.json);;XML Files (*.xml);;")
62 try: 61 with contextlib.suppress(ImportError):
63 import yaml # __IGNORE_WARNING__ 62 import yaml # __IGNORE_WARNING__
64 fileFilters += self.tr("YAML Files (*.yaml);;") 63 fileFilters += self.tr("YAML Files (*.yaml);;")
65 except ImportError:
66 pass
67 fileFilters += self.tr("All Files (*)") 64 fileFilters += self.tr("All Files (*)")
68 65
69 fixtureFiles = E5FileDialog.getOpenFileNames( 66 fixtureFiles = E5FileDialog.getOpenFileNames(
70 self, 67 self,
71 self.tr("Select fixture file"), 68 self.tr("Select fixture file"),

eric ide

mercurial