forked from CEN-RA/Plugin_QGIS
Fix de bug et optimisation d'exécution.
This commit is contained in:
parent
9b438f5bf1
commit
670c698b77
@ -188,7 +188,7 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
|||||||
con = psycopg2.connect("host=" + host + " port=" + port + " dbname=" + dbtype + " user=" + user + " password=" + mdp)
|
con = psycopg2.connect("host=" + host + " port=" + port + " dbname=" + dbtype + " user=" + user + " password=" + mdp)
|
||||||
cur = con.cursor(cursor_factory=psycopg2.extras.DictCursor)
|
cur = con.cursor(cursor_factory=psycopg2.extras.DictCursor)
|
||||||
self.combobox_custom()
|
self.combobox_custom()
|
||||||
# self.initialisation_flux()
|
self.initialisation_flux()
|
||||||
# Create the dialog with elements (after translation) and keep reference
|
# Create the dialog with elements (after translation) and keep reference
|
||||||
# Only create GUI ONCE in callback, so that it will only load when the plugin is started
|
# Only create GUI ONCE in callback, so that it will only load when the plugin is started
|
||||||
if self.first_start is True:
|
if self.first_start is True:
|
||||||
@ -212,7 +212,7 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
|||||||
con = psycopg2.connect("host=" + host + " port=" + port + " dbname=" + dbtype + " user=" + user + " password=" + mdp)
|
con = psycopg2.connect("host=" + host + " port=" + port + " dbname=" + dbtype + " user=" + user + " password=" + mdp)
|
||||||
cur = con.cursor(cursor_factory=psycopg2.extras.DictCursor)
|
cur = con.cursor(cursor_factory=psycopg2.extras.DictCursor)
|
||||||
self.combobox_custom()
|
self.combobox_custom()
|
||||||
# self.initialisation_flux()
|
self.initialisation_flux()
|
||||||
# Create the dialog with elements (after translation) and keep reference
|
# Create the dialog with elements (after translation) and keep reference
|
||||||
# Only create GUI ONCE in callback, so that it will only load when the plugin is started
|
# Only create GUI ONCE in callback, so that it will only load when the plugin is started
|
||||||
if self.first_start is True:
|
if self.first_start is True:
|
||||||
@ -231,7 +231,8 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.tableWidget_2.removeRow(self.tableWidget_2.currentRow())
|
self.tableWidget_2.removeRow(self.tableWidget_2.currentRow())
|
||||||
|
|
||||||
def initialisation_flux(self):
|
def initialisation_flux(self):
|
||||||
print('run')
|
if NoSignals == 0:
|
||||||
|
# print('Initiaisation de la connection a la DB: ' + dbtype)
|
||||||
if dbtype == sigdb:
|
if dbtype == sigdb:
|
||||||
# self.toolButton.setEnabled(1)
|
# self.toolButton.setEnabled(1)
|
||||||
if self.comboBox.currentText() == 'toutes les catégories':
|
if self.comboBox.currentText() == 'toutes les catégories':
|
||||||
@ -278,13 +279,15 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
|||||||
if self.comboBox.currentText() == 'toutes les catégories':
|
if self.comboBox.currentText() == 'toutes les catégories':
|
||||||
SQLGrands = """SELECT concat(table_schema,'.',table_name) FROM information_schema.role_table_grants WHERE grantee in(SELECT rolname FROM pg_catalog.pg_roles WHERE oid in(SELECT roleid FROM pg_auth_members WHERE member = (SELECT usesysid FROM pg_catalog.pg_user WHERE usename = '""" + user + """'))) and privilege_type = 'SELECT';"""
|
SQLGrands = """SELECT concat(table_schema,'.',table_name) FROM information_schema.role_table_grants WHERE grantee in(SELECT rolname FROM pg_catalog.pg_roles WHERE oid in(SELECT roleid FROM pg_auth_members WHERE member = (SELECT usesysid FROM pg_catalog.pg_user WHERE usename = '""" + user + """'))) and privilege_type = 'SELECT';"""
|
||||||
else:
|
else:
|
||||||
|
if dbtype == sigdb:
|
||||||
SQLGrands = """SELECT concat(table_schema,'.',table_name) FROM information_schema.role_table_grants WHERE grantee in(SELECT rolname FROM pg_catalog.pg_roles WHERE oid in(SELECT roleid FROM pg_auth_members WHERE member = (SELECT usesysid FROM pg_catalog.pg_user WHERE usename = '""" + user + """'))) and privilege_type = 'SELECT' AND table_schema LIKE '_""" + str(self.comboBox.currentText()) + """_%';"""
|
SQLGrands = """SELECT concat(table_schema,'.',table_name) FROM information_schema.role_table_grants WHERE grantee in(SELECT rolname FROM pg_catalog.pg_roles WHERE oid in(SELECT roleid FROM pg_auth_members WHERE member = (SELECT usesysid FROM pg_catalog.pg_user WHERE usename = '""" + user + """'))) and privilege_type = 'SELECT' AND table_schema LIKE '_""" + str(self.comboBox.currentText()) + """_%';"""
|
||||||
|
elif dbtype == refdb:
|
||||||
|
SQLGrands = """SELECT concat(table_schema,'.',table_name) FROM information_schema.role_table_grants WHERE grantee in(SELECT rolname FROM pg_catalog.pg_roles WHERE oid in(SELECT roleid FROM pg_auth_members WHERE member = (SELECT usesysid FROM pg_catalog.pg_user WHERE usename = '""" + user + """'))) and privilege_type = 'SELECT' AND table_schema LIKE '""" + str(self.comboBox.currentText()) + """%';"""
|
||||||
cur.execute(SQLGrands)
|
cur.execute(SQLGrands)
|
||||||
list_grands = cur.fetchall()
|
list_grands = cur.fetchall()
|
||||||
GrandUser = []
|
GrandUser = []
|
||||||
for grandsFind in list_grands:
|
for grandsFind in list_grands:
|
||||||
GrandUser.append(grandsFind[0])
|
GrandUser.append(grandsFind[0])
|
||||||
|
|
||||||
self.tableWidget.setRowCount(len(list_schema))
|
self.tableWidget.setRowCount(len(list_schema))
|
||||||
self.tableWidget.setColumnCount(4)
|
self.tableWidget.setColumnCount(4)
|
||||||
i = 0
|
i = 0
|
||||||
@ -335,7 +338,7 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
|||||||
item = QTableWidgetItem(table_name)
|
item = QTableWidgetItem(table_name)
|
||||||
self.tableWidget.setItem(i, 3, item)
|
self.tableWidget.setItem(i, 3, item)
|
||||||
|
|
||||||
if dbtype == sigdb:
|
# if dbtype == sigdb:
|
||||||
if (str(value[0]) + '.' + str(value[1])) in GrandUser:
|
if (str(value[0]) + '.' + str(value[1])) in GrandUser:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@ -384,6 +387,9 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.tableWidget.setColumnWidth(3, 300)
|
self.tableWidget.setColumnWidth(3, 300)
|
||||||
self.tableWidget.setHorizontalHeaderLabels(["Type", "Code", "Schema", "Table"])
|
self.tableWidget.setHorizontalHeaderLabels(["Type", "Code", "Schema", "Table"])
|
||||||
|
|
||||||
|
if self.lineEdit.text() != 'Recherche par mots-clés':
|
||||||
|
self.filtre_dynamique(self.lineEdit.text())
|
||||||
|
|
||||||
def selection_flux(self):
|
def selection_flux(self):
|
||||||
selected_row = 0
|
selected_row = 0
|
||||||
selected_items = self.tableWidget.selectedItems()
|
selected_items = self.tableWidget.selectedItems()
|
||||||
@ -554,6 +560,9 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.QMBquestion = QMessageBox.question(iface.mainWindow(), u"Attention !", "La couche «" + str(self.tableWidget_2.item(row, 1).text()) + ' ' + str(self.tableWidget_2.item(row, 2).text()) + "» ne ce trouve pas dans cette BD !", QMessageBox.StandardButton(0x00004000))
|
self.QMBquestion = QMessageBox.question(iface.mainWindow(), u"Attention !", "La couche «" + str(self.tableWidget_2.item(row, 1).text()) + ' ' + str(self.tableWidget_2.item(row, 2).text()) + "» ne ce trouve pas dans cette BD !", QMessageBox.StandardButton(0x00004000))
|
||||||
|
|
||||||
def combobox_custom(self):
|
def combobox_custom(self):
|
||||||
|
# print('Chargement de la list pour la BD: ' + dbtype)
|
||||||
|
global NoSignals
|
||||||
|
NoSignals = 1
|
||||||
if dbtype == sigdb:
|
if dbtype == sigdb:
|
||||||
self.toolButton.setEnabled(1)
|
self.toolButton.setEnabled(1)
|
||||||
self.comboBox.clear()
|
self.comboBox.clear()
|
||||||
@ -577,6 +586,7 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.comboBox.addItem("toutes les catégories")
|
self.comboBox.addItem("toutes les catégories")
|
||||||
for baxval in list_schema:
|
for baxval in list_schema:
|
||||||
self.comboBox.addItem(baxval[0])
|
self.comboBox.addItem(baxval[0])
|
||||||
|
NoSignals = 0
|
||||||
|
|
||||||
def filtre_dynamique(self, filter_text):
|
def filtre_dynamique(self, filter_text):
|
||||||
if filter_text.find(' ') >= 0:
|
if filter_text.find(' ') >= 0:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user