Show psql grands
This commit is contained in:
parent
26678fb257
commit
d50f601bd9
@ -275,6 +275,16 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
||||
cur.execute(SQLProjectsQgis)
|
||||
list_projects_qgis.append(cur.fetchall())
|
||||
|
||||
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';"""
|
||||
else:
|
||||
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)
|
||||
list_grands = cur.fetchall()
|
||||
GrandUser = []
|
||||
for grandsFind in list_grands:
|
||||
GrandUser.append(grandsFind[0])
|
||||
|
||||
self.tableWidget.setRowCount(len(list_schema))
|
||||
self.tableWidget.setColumnCount(4)
|
||||
i = 0
|
||||
@ -324,6 +334,15 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
||||
self.tableWidget.setItem(i, 2, item)
|
||||
item = QTableWidgetItem(table_name)
|
||||
self.tableWidget.setItem(i, 3, item)
|
||||
|
||||
if (str(value[0]) + '.' + str(value[1])) in GrandUser:
|
||||
pass
|
||||
else:
|
||||
# print(str(value[0]) + '.' + str(value[1]), 'bad')
|
||||
for j in range(self.tableWidget.columnCount()):
|
||||
self.tableWidget.item(i, j).setBackground(QtGui.QColor(187, 134, 192, 50))
|
||||
self.tableWidget.item(i, j).setToolTip('Droit insuffisant pour ouvrire la couche !')
|
||||
|
||||
i = i + 1
|
||||
|
||||
if self.comboBox.currentText() == 'toutes les catégories':
|
||||
@ -332,6 +351,7 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
||||
SQLprojects = """SELECT schemaname, tablename FROM pg_catalog.pg_tables WHERE tablename LIKE 'qgis_projects' AND schemaname LIKE '""" + str(self.comboBox.currentText()) + """';"""
|
||||
cur.execute(SQLprojects)
|
||||
list_projects = cur.fetchall()
|
||||
|
||||
list_projects_qgis = []
|
||||
if len(list_projects) >= 1:
|
||||
for ProjectName in list_projects:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user