Sécurité et restriction en plus
This commit is contained in:
parent
1a17bb7d7c
commit
49b78e58ac
@ -36,7 +36,7 @@ import base64
|
|||||||
from qgis.utils import iface
|
from qgis.utils import iface
|
||||||
|
|
||||||
EDITOR_CLASS = load_ui('CenRa_PostgisRename_base.ui')
|
EDITOR_CLASS = load_ui('CenRa_PostgisRename_base.ui')
|
||||||
|
ch = [u"à", u"À", u"â", u"Â", u"ä", u"Ä", u"å", u"Å", u"ç", u"Ç", u"é", u"É", u"è", u"È", u"ê", u"Ê", u"ë", u"Ë", u"î", u"Î", u"ï", u"Ï", u"ô", u"Ô", u"ö", u"Ö", u"ù", u"Ù", u"û", u"Û", u"ü", u"Ü", u"ÿ", u"Ÿ", u"'", u"-", u" "]
|
||||||
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password)
|
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password)
|
||||||
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
|
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
|
||||||
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')")
|
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')")
|
||||||
@ -83,14 +83,41 @@ class Postgis_Rename(QDialog, EDITOR_CLASS):
|
|||||||
self.departement.setCurrentIndex(self.departement.findText(last_value_departement))
|
self.departement.setCurrentIndex(self.departement.findText(last_value_departement))
|
||||||
|
|
||||||
def Test(self):
|
def Test(self):
|
||||||
if self.schema.currentText() != '':
|
oldSchema = self.schema.currentText()
|
||||||
|
if oldSchema != '':
|
||||||
allIsGood = 0
|
allIsGood = 0
|
||||||
|
|
||||||
|
GET_COUNT_LEFT = "SELECT count(*) FROM information_schema.tables WHERE table_schema LIKE left(table_name,"+str(len(oldSchema))+") AND table_schema LIKE '"+oldSchema+"';"
|
||||||
|
GET_COUNT_TOT = "SELECT count(*) FROM information_schema.tables WHERE table_schema LIKE '"+oldSchema+"';"
|
||||||
|
|
||||||
|
cur.execute(GET_COUNT_TOT)
|
||||||
|
CountTot = cur.fetchall()[0]
|
||||||
|
cur.execute(GET_COUNT_LEFT)
|
||||||
|
CountLeft = cur.fetchall()[0]
|
||||||
|
|
||||||
|
if CountLeft[0] == CountTot[0]:
|
||||||
|
allIsGood = allIsGood+1
|
||||||
|
self.couche.setChecked(1)
|
||||||
|
else:
|
||||||
|
self.couche.setChecked(0)
|
||||||
|
|
||||||
|
GET_GRANTEE_PRIVILEGE = "SELECT DISTINCT count(*) FROM information_schema.role_table_grants WHERE table_schema LIKE '"+oldSchema+"' AND grantee LIKE 'grp_qgis' AND privilege_type LIKE 'UPDATE';"
|
||||||
|
cur.execute(GET_GRANTEE_PRIVILEGE)
|
||||||
|
CountPrivilege = cur.fetchall()[0]
|
||||||
|
|
||||||
|
if CountTot[0] == CountPrivilege[0]:
|
||||||
|
allIsGood = allIsGood+1
|
||||||
|
self.compte.setChecked(1)
|
||||||
|
else:
|
||||||
|
self.compte.setChecked(0)
|
||||||
|
|
||||||
if allIsGood == 2:
|
if allIsGood == 2:
|
||||||
self.groupBox_3.show()
|
self.groupBox_3.show()
|
||||||
self.loadValue()
|
self.loadValue()
|
||||||
self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(True)
|
self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(True)
|
||||||
|
else:
|
||||||
|
self.groupBox_3.hide()
|
||||||
|
self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
|
||||||
else:
|
else:
|
||||||
self.old_name.setText('')
|
self.old_name.setText('')
|
||||||
|
|
||||||
@ -189,6 +216,16 @@ class Postgis_Rename(QDialog, EDITOR_CLASS):
|
|||||||
self.QMBquestion.setIcon(QMessageBox.Warning)
|
self.QMBquestion.setIcon(QMessageBox.Warning)
|
||||||
self.QMBquestion.setText("Attention, le renommage de dossier PostGIS peut engendrer des pertes de liaisons avec des projets QGIS !")
|
self.QMBquestion.setText("Attention, le renommage de dossier PostGIS peut engendrer des pertes de liaisons avec des projets QGIS !")
|
||||||
self.QMBquestion.setStandardButtons(QMessageBox.Yes|QMessageBox.No)
|
self.QMBquestion.setStandardButtons(QMessageBox.Yes|QMessageBox.No)
|
||||||
self.QMBquestion = self.QMBquestion.exec()
|
if self.new_name.text() != '':
|
||||||
|
error_caracteres = 0
|
||||||
|
for caracteres in ch :
|
||||||
|
if self.new_name.text().find(caracteres) != -1 :
|
||||||
|
error_caracteres = 1
|
||||||
|
if error_caracteres == 0:
|
||||||
|
self.QMBquestion = self.QMBquestion.exec()
|
||||||
|
else:
|
||||||
|
QMessageBox.warning(None, "Oups :", u"Le nom de dossier ne doit pas comporter de caractères spéciaux, ni d'espaces !\n\n\t" + self.new_name.text().lower() )
|
||||||
|
else:
|
||||||
|
QMessageBox.warning(None, "Oups :", "Votre projet doit avoire un nom !")
|
||||||
if self.QMBquestion == QMessageBox.Yes:
|
if self.QMBquestion == QMessageBox.Yes:
|
||||||
self.updateName()
|
self.updateName()
|
||||||
|
|||||||
@ -94,7 +94,7 @@
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QCheckBox" name="checkBox">
|
<widget class="QCheckBox" name="compte">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -117,7 +117,7 @@
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QCheckBox" name="checkBox_2">
|
<widget class="QCheckBox" name="couche">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user