|
31 | 31 | QCoreApplication, |
32 | 32 | Qt, |
33 | 33 | QStandardPaths, |
| 34 | + QUrl, |
34 | 35 | QDir |
35 | 36 | ) |
36 | 37 | from qgis.PyQt.QtGui import ( |
37 | | - QKeySequence |
| 38 | + QKeySequence, |
| 39 | + QDesktopServices |
38 | 40 | ) |
39 | 41 | from qgis.PyQt.QtWidgets import ( |
40 | 42 | QApplication, |
|
52 | 54 | QgsApplication, |
53 | 55 | QgsTask |
54 | 56 | ) |
| 57 | + |
55 | 58 | from qgis.gui import ( |
56 | 59 | QgsLayoutDesignerInterface |
57 | 60 | ) |
@@ -1244,7 +1247,10 @@ def loadModules(self): |
1244 | 1247 | username = globals.APP_DBCONN.User.UserName |
1245 | 1248 |
|
1246 | 1249 | if username == 'postgres': |
1247 | | - self.grant_privilege_base_tables(username) |
| 1250 | + if self.grant_privilege_base_tables(username): |
| 1251 | + LOGGER.info('Privileges granted to base tables.') |
| 1252 | + else: |
| 1253 | + LOGGER.error('Failed to grant privilege to base tables.') |
1248 | 1254 |
|
1249 | 1255 | self.moduleCntGroup = None |
1250 | 1256 | self.moduleContentGroups = [] |
@@ -1492,14 +1498,29 @@ def _doc_temp_exist(self, doc_temp, profile_templates): |
1492 | 1498 | break |
1493 | 1499 | return doc_exist |
1494 | 1500 |
|
1495 | | - def grant_privilege_base_tables(self, username): |
| 1501 | + def grant_privilege_base_tables(self, username) ->bool: |
1496 | 1502 | roles = [] |
1497 | | - roleProvider = RoleProvider() |
1498 | | - roles = roleProvider.GetSysRoles() |
| 1503 | + try: |
| 1504 | + roleProvider = RoleProvider() |
| 1505 | + roles = roleProvider.GetSysRoles() |
| 1506 | + |
| 1507 | + privilege_provider = SinglePrivilegeProvider('', current_profile()) |
| 1508 | + for role in roles: |
| 1509 | + privilege_provider.grant_privilege_base_table(role) |
| 1510 | + except ConfigurationException as c_ex: |
| 1511 | + QMessageBox.information( |
| 1512 | + self.iface.mainWindow(), |
| 1513 | + QApplication.translate( |
| 1514 | + 'STDM', |
| 1515 | + 'Grant privilege base tables' |
| 1516 | + ), |
| 1517 | + str(c_ex)) |
| 1518 | + return False |
| 1519 | + |
| 1520 | + return True |
| 1521 | + |
| 1522 | + |
1499 | 1523 |
|
1500 | | - privilege_provider = SinglePrivilegeProvider('', current_profile()) |
1501 | | - for role in roles: |
1502 | | - privilege_provider.grant_privilege_base_table(role) |
1503 | 1524 |
|
1504 | 1525 | def load_profiles_combobox(self): |
1505 | 1526 | """ |
@@ -2220,21 +2241,45 @@ def user_entities(self): |
2220 | 2241 |
|
2221 | 2242 | def help_contents(self): |
2222 | 2243 | """ |
2223 | | - Load and open documentation manual |
| 2244 | + Open documentation manual |
2224 | 2245 | """ |
| 2246 | + HELP_URL = "https://www.stdm.gltn.net/docs/1_8/STDM_1.8.1_User_Manual.pdf" |
| 2247 | + |
2225 | 2248 | help_manual = '{0}/stdm.chm'.format(self.plugin_dir) |
2226 | 2249 |
|
2227 | 2250 | try: |
2228 | 2251 | os.startfile( |
2229 | 2252 | help_manual, 'open' |
2230 | 2253 | ) |
2231 | 2254 | except FileNotFoundError as ex: |
2232 | | - QMessageBox.critical( |
2233 | | - self.iface.mainWindow(), |
2234 | | - QApplication.translate( |
2235 | | - "STDMQGISLoader", |
2236 | | - 'Open File Error' |
2237 | | - ), str("Error trying to open help file (stdm.chm), file is missing.")) |
| 2255 | + if self.view_online_user_manual(): |
| 2256 | + ds = QDesktopServices() |
| 2257 | + ds.openUrl(QUrl(HELP_URL)) |
| 2258 | + |
| 2259 | + |
| 2260 | + def view_online_user_manual(self) -> bool: |
| 2261 | + msg_box = QMessageBox() |
| 2262 | + msg_box.setIcon(QMessageBox.Critical) |
| 2263 | + msg_box.setWindowTitle(QApplication.translate( |
| 2264 | + "STDMQGISLoader", |
| 2265 | + "STDM Help File Error")) |
| 2266 | + msg_box.setText(QApplication.translate( |
| 2267 | + "STDMQGISLoader", |
| 2268 | + "Local version of the help file (stdm.chm) file is missing.")) |
| 2269 | + msg_box.setInformativeText(QApplication.translate( |
| 2270 | + "STDMQGISLoader", |
| 2271 | + 'Would you like to open the online help?')) |
| 2272 | + msg_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No) |
| 2273 | + msg_box.setDefaultButton(QMessageBox.Yes) |
| 2274 | + |
| 2275 | + yes_btn = msg_box.button(QMessageBox.Yes) |
| 2276 | + |
| 2277 | + msg_box.exec_() |
| 2278 | + if msg_box.clickedButton() == yes_btn: |
| 2279 | + return True |
| 2280 | + else: |
| 2281 | + return False |
| 2282 | + |
2238 | 2283 |
|
2239 | 2284 | def reset_content_modules_id(self, title, message_text): |
2240 | 2285 | return QMessageBox.critical( |
|
0 commit comments