Skip to content

Commit 548d2f4

Browse files
committed
Help: Connect to the online help manual
This fix add's ability to connect to the online user manual if the local help file is missing. The patch also fixes other minor issues related to data types in the Qt API function calls - see document_viewer file for those changes.
1 parent f71716f commit 548d2f4

8 files changed

Lines changed: 75 additions & 24 deletions

File tree

stdm/data/configuration/columns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def on_delete(self):
268268
"""
269269
pass
270270

271-
def dependencies(self):
271+
def dependencies(self) ->dict:
272272
"""
273273
Gets the tables and views that are related to this column.
274274
:return: A dictionary containing a list of related entity names and

stdm/plugin.py

Lines changed: 60 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@
3131
QCoreApplication,
3232
Qt,
3333
QStandardPaths,
34+
QUrl,
3435
QDir
3536
)
3637
from qgis.PyQt.QtGui import (
37-
QKeySequence
38+
QKeySequence,
39+
QDesktopServices
3840
)
3941
from qgis.PyQt.QtWidgets import (
4042
QApplication,
@@ -52,6 +54,7 @@
5254
QgsApplication,
5355
QgsTask
5456
)
57+
5558
from qgis.gui import (
5659
QgsLayoutDesignerInterface
5760
)
@@ -1244,7 +1247,10 @@ def loadModules(self):
12441247
username = globals.APP_DBCONN.User.UserName
12451248

12461249
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.')
12481254

12491255
self.moduleCntGroup = None
12501256
self.moduleContentGroups = []
@@ -1492,14 +1498,29 @@ def _doc_temp_exist(self, doc_temp, profile_templates):
14921498
break
14931499
return doc_exist
14941500

1495-
def grant_privilege_base_tables(self, username):
1501+
def grant_privilege_base_tables(self, username) ->bool:
14961502
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+
14991523

1500-
privilege_provider = SinglePrivilegeProvider('', current_profile())
1501-
for role in roles:
1502-
privilege_provider.grant_privilege_base_table(role)
15031524

15041525
def load_profiles_combobox(self):
15051526
"""
@@ -2220,21 +2241,45 @@ def user_entities(self):
22202241

22212242
def help_contents(self):
22222243
"""
2223-
Load and open documentation manual
2244+
Open documentation manual
22242245
"""
2246+
HELP_URL = "https://www.stdm.gltn.net/docs/1_8/STDM_1.8.1_User_Manual.pdf"
2247+
22252248
help_manual = '{0}/stdm.chm'.format(self.plugin_dir)
22262249

22272250
try:
22282251
os.startfile(
22292252
help_manual, 'open'
22302253
)
22312254
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+
22382283

22392284
def reset_content_modules_id(self, title, message_text):
22402285
return QMessageBox.critical(

stdm/ui/document_viewer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def update_size(self, doc_width, doc_height):
352352
if par_height > doc_height and par_width > doc_width:
353353
self.resize(doc_width, doc_height)
354354
else:
355-
self.resize(doc_width * ratio, doc_height * ratio)
355+
self.resize(doc_width * int(ratio), doc_height * int(ratio))
356356

357357
def closeEvent(self, event):
358358
"""
@@ -416,7 +416,7 @@ def center(self):
416416
# vertical position
417417
vpos = (screen.height() - mdi_area_size.height()) / 2
418418
# repositions the window
419-
self.move(hpos, vpos)
419+
self.move(int(hpos), int(vpos))
420420

421421
def _create_menu_actions(self):
422422
self._window_menu = self.menuBar().addMenu(

stdm/ui/geoodk_profile_importer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ def save_instance_data_to_db(self, entities : List[str], xml_files: List[str]) -
651651
# Check if the file exists in the log file
652652
if xml_filename in log_data:
653653
msg = f"File `{xml_filename}` already imported. Skipping..."
654+
self.txt_feedback.append(msg)
654655
self.importlogger.log_info(msg)
655656
continue
656657

stdm/ui/sourcedocument.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ def onBlockWritten(self, size):
946946
"""
947947
progress = (size * 100) / self._docSize
948948

949-
self.pgBar.setValue(progress)
949+
self.pgBar.setValue(int(progress))
950950
#QgsApplication.processEvents()
951951

952952
def onCompleteTransfer(self, fileid):

stdm/ui/wizard/column_editor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,6 @@ def create_column(self) -> BaseColumn:
804804
self.entity, **self.form_fields
805805
)
806806

807-
808807
def property_set(self):
809808
self.prop_set = True
810809
self.type_attribs[self.current_type_info()]['prop_set'] = True

stdm/ui/wizard/create_lookup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def accept(self):
180180

181181
if self.lookup is None: # new lookup
182182
if self.duplicate_check(short_name):
183-
self.show_message(
183+
self.error_message(
184184
self.tr(
185185
"Lookup with the same name already "
186186
"exist in the current profile!"

stdm/ui/wizard/wizard.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,7 +2538,7 @@ def process_privilege(self, entity, column):
25382538
if new_content is None: return
25392539
self.update_privilege_cache(entity, column, new_content)
25402540

2541-
def column_has_entity_relation(self, column):
2541+
def column_has_entity_relation(self, column: 'Column') ->bool:
25422542
answer = False
25432543
if (isinstance(column, ForeignKeyColumn) or
25442544
isinstance(column, AdministrativeSpatialUnitColumn)):
@@ -2810,6 +2810,11 @@ def delete_lookup(self):
28102810
# the current profile
28112811
dependencies = self.all_column_dependencies(profile)
28122812

2813+
print('------------------')
2814+
print(dependencies)
2815+
print(lookup.name)
2816+
print('------------------')
2817+
28132818
if self.find_lookup(lookup.name, dependencies):
28142819
self.show_message(self.tr("Cannot delete '{0}' lookup!\n "
28152820
"Lookup is been used by existing columns."
@@ -2829,7 +2834,7 @@ def delete_lookup(self):
28292834
self.lookup_view_model.removeRow(row_id)
28302835
self.refresh_lookup_view()
28312836

2832-
def all_column_dependencies(self, profile):
2837+
def all_column_dependencies(self, profile:Profile) -> list:
28332838
"""
28342839
Returns a list of all column dependencies, for all
28352840
enitites in the current profile
@@ -2849,7 +2854,7 @@ def all_column_dependencies(self, profile):
28492854
depends.append(column.dependencies())
28502855
return depends
28512856

2852-
def find_lookup(self, name, dependencies):
2857+
def find_lookup(self, name, dependencies:list) -> list:
28532858
"""
28542859
Returns True if name is in the list of dependencies
28552860
else False
@@ -2859,6 +2864,7 @@ def find_lookup(self, name, dependencies):
28592864
:type dependencies: list
28602865
:rtype: boolean
28612866
"""
2867+
28622868
for depend in dependencies:
28632869
if name in depend['entities']:
28642870
return True

0 commit comments

Comments
 (0)