Skip to content

Commit

Permalink
Merge branch 'dev-3.6' into master-3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
smaspons committed Sep 13, 2023
2 parents e1e473c + 5e7c86a commit a5e54c5
Show file tree
Hide file tree
Showing 51 changed files with 10,511 additions and 14,239 deletions.
8 changes: 5 additions & 3 deletions config/giswater.config
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ om = 26, 27, 56, 57, 43, 64, 65, 84
edit = 01, 02, 16, 17, 28, 44, 20, 68, 69, 39, 34, 66, 33, 67
cad = 71, 72
epa = 218, 23, 25, 29, 215
plan = 45, 46, 50
utilities = 99, 206, 214, 58, 83, 59
plan = 45, 46, 219
utilities = 217, 99, 206, 214, 58, 83, 59
toc = 306, 308

[project_exclude]
ws = 43, 56, 57
ud = 26, 27
ud = 26, 27, 219

[buttons_def]
# basic
Expand Down Expand Up @@ -72,13 +72,15 @@ ud = 26, 27
45 = GwPsectorButton
46 = GwPsectorManagerButton
50 = GwPriceManagerButton
219 = GwNetscenarioManagerButton
# utilities
58 = GwPrintButton
59 = GwProjectCheckButton
83 = GwCSVButton
99 = GwConfigButton
214 = GwWorkspaceManagerButton
206 = GwToolBoxButton
217 = GwUtilsManagerButton
# toc
306 = GwAddChildLayerButton
308 = GwEpaWorldButton
Expand Down
89 changes: 89 additions & 0 deletions config/user_params.config
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,14 @@ _info_epa_pump_width = None
_info_epa_pump_height = None
_info_epa_weir_width = None
_info_epa_weir_height = None
_dlg_mapzone_manager_width = None
_dlg_mapzone_manager_height = None
_dlg_netscenario_manager_width = None
_dlg_netscenario_manager_height = None
_dlg_mapzone_config_width = None
_dlg_mapzone_config_height = None
_dlg_netscenario_width = None
_dlg_netscenario_height = None

[session.dialogs_position]
dlg_admin_translation_x = None
Expand Down Expand Up @@ -496,11 +504,20 @@ _info_epa_pump_x = None
_info_epa_pump_y = None
_info_epa_weir_x = None
_info_epa_weir_y = None
_dlg_mapzone_manager_x = None
_dlg_mapzone_manager_y = None
_dlg_netscenario_manager_x = None
_dlg_netscenario_manager_y = None
_dlg_mapzone_config_x = None
_dlg_mapzone_config_y = None
_dlg_netscenario_x = None
_dlg_netscenario_y = None

[session.dialogs_tab]
_dlg_selector_basic = None
_dlg_selector_mincut = None
_selector_basic = None
_dlg_selector_netscenario = None

[session.btn_search]
_search_csv_path = None
Expand Down Expand Up @@ -796,6 +813,78 @@ _gw_fct_graphanalytics_minsector_updatefeature = None
_gw_fct_graphanalytics_minsector_geomparamupdate = None
_gw_fct_graphanalytics_minsector_updatemapzone = None
_gw_fct_graphanalytics_mapzones_advanced_commitchanges = None
_gw_fct_epa_setjunctionsoutlet_cmb_feature_type = None
_gw_fct_epa_setjunctionsoutlet_cmb_layers = None
_gw_fct_epa_setjunctionsoutlet_rbt_previous = None
_gw_fct_epa_setjunctionsoutlet_mindistance = None
_gw_fct_create_netscenario_empty_cmb_feature_type = None
_gw_fct_create_netscenario_empty_cmb_layers = None
_gw_fct_create_netscenario_empty_rbt_previous = None
_gw_fct_create_netscenario_empty_name = None
_gw_fct_create_netscenario_empty_descript = None
_gw_fct_create_netscenario_empty_type = None
_gw_fct_create_netscenario_empty_active = None
_gw_fct_create_netscenario_empty_expl = None
_gw_fct_duplicate_netscenario_cmb_feature_type = None
_gw_fct_duplicate_netscenario_cmb_layers = None
_gw_fct_duplicate_netscenario_rbt_previous = None
_gw_fct_duplicate_netscenario_copyfrom = None
_gw_fct_duplicate_netscenario_name = None
_gw_fct_duplicate_netscenario_descript = None
_gw_fct_duplicate_netscenario_parent = None
_gw_fct_duplicate_netscenario_active = None
_gw_fct_graphanalytics_mapzones_plan_cmb_feature_type = None
_gw_fct_graphanalytics_mapzones_plan_cmb_layers = None
_gw_fct_graphanalytics_mapzones_plan_rbt_previous = None
_gw_fct_graphanalytics_mapzones_plan_netscenario = None
_gw_fct_graphanalytics_mapzones_plan_floodonlymapzone = None
_gw_fct_graphanalytics_mapzones_plan_forceopen = None
_gw_fct_graphanalytics_mapzones_plan_forceclosed = None
_gw_fct_graphanalytics_mapzones_plan_dscenario_valve = None
_gw_fct_graphanalytics_mapzones_plan_useplanpsector = None
_gw_fct_graphanalytics_mapzones_plan_updatemapzone = None
_gw_fct_graphanalytics_mapzones_plan_geomparamupdate = None
_gw_fct_create_netscenario_from_toc_cmb_feature_type = None
_gw_fct_create_netscenario_from_toc_cmb_layers = None
_gw_fct_create_netscenario_from_toc_rbt_previous = None
_gw_fct_create_netscenario_from_toc_name = None
_gw_fct_create_netscenario_from_toc_descript = None
_gw_fct_create_netscenario_from_toc_type = None
_gw_fct_create_netscenario_from_toc_active = None
_gw_fct_create_netscenario_from_toc_expl = None
_gw_fct_graphanalytics_hydrant_cmb_feature_type = None
_gw_fct_graphanalytics_hydrant_cmb_layers = None
_gw_fct_graphanalytics_hydrant_rbt_previous = None
_gw_fct_graphanalytics_hydrant_useproposal = None
_gw_fct_graphanalytics_hydrant_usepsector = None
_gw_fct_massivemincut_cmb_feature_type = None
_gw_fct_massivemincut_cmb_layers = None
_gw_fct_massivemincut_rbt_previous = None
_gw_fct_massivemincut_exploitation = None
_gw_fct_setclosestaddress_cmb_feature_type = None
_gw_fct_setclosestaddress_cmb_layers = None
_gw_fct_setclosestaddress_rbt_previous = None
_gw_fct_setclosestaddress_catfeature = None
_gw_fct_setclosestaddress_fieldtoupdate = None
_gw_fct_setclosestaddress_updatevalues = None
_gw_fct_setclosestaddress_insersectpolygonlayer = None
_gw_fct_config_feature_border_cmb_feature_type = None
_gw_fct_config_feature_border_cmb_layers = None
_gw_fct_config_feature_border_rbt_previous = None
_gw_fct_config_feature_border_configzone = None
_gw_fct_graphanalytics_check_data_cmb_feature_type = None
_gw_fct_graphanalytics_check_data_cmb_layers = None
_gw_fct_graphanalytics_check_data_rbt_previous = None
_gw_fct_graphanalytics_flowtrace_cmb_feature_type = None
_gw_fct_graphanalytics_flowtrace_cmb_layers = None
_gw_fct_graphanalytics_flowtrace_rbt_previous = None
_gw_fct_graphanalytics_flowtrace_nodeid = None
_gw_fct_mincut_show_current_cmb_feature_type = None
_gw_fct_mincut_show_current_cmb_layers = None
_gw_fct_mincut_show_current_rbt_previous = None
_gw_fct_anl_node_tcandidate_cmb_feature_type = None
_gw_fct_anl_node_tcandidate_cmb_layers = None
_gw_fct_anl_node_tcandidate_rbt_previous = None

[session.docker]
_position = None
Expand Down
9 changes: 9 additions & 0 deletions core/shared/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,9 @@ def _manage_element_accept(self, table_object):
f" WHERE element_id = '{element_id}';")
sql += (f"\nDELETE FROM element_x_connec"
f" WHERE element_id = '{element_id}';")
if global_vars.project_type == 'ud':
sql += (f"\nDELETE FROM element_x_gully"
f" WHERE element_id = '{element_id}';")

if self.list_ids['arc']:
for feature_id in self.list_ids['arc']:
Expand All @@ -555,10 +558,16 @@ def _manage_element_accept(self, table_object):
for feature_id in self.list_ids['connec']:
sql += (f"\nINSERT INTO element_x_connec (element_id, connec_id)"
f" VALUES ('{element_id}', '{feature_id}');")
if self.list_ids['gully']:
for feature_id in self.list_ids['gully']:
sql += (f"\nINSERT INTO element_x_gully (element_id, gully_id)"
f" VALUES ('{element_id}', '{feature_id}');")
status = tools_db.execute_sql(sql)
if status:
self.element_id = element_id
self.layers = tools_gw.manage_close(self.dlg_add_element, table_object, layers=self.layers)
# Refresh canvas
tools_qgis.refresh_map_canvas()


def _filter_elementcat_id(self):
Expand Down
14 changes: 12 additions & 2 deletions core/shared/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ def open_form(self, point=None, table_name=None, feature_id=None, feature_cat=No
else:
sub_tag = 'node'
feature_id = self.complet_result['body']['feature']['id']

result, dialog = self._open_custom_form(feature_id, self.complet_result, tab_type, sub_tag, is_docker,
new_feature=new_feature)
if feature_cat is not None:
Expand Down Expand Up @@ -504,12 +505,15 @@ def _open_custom_form(self, feature_id, complet_result, tab_type=None, sub_tag=N
pass

self.visible_tabs = complet_result['body']['form'].get('visibleTabs', [])

for tab in self.visible_tabs:
tabs_to_show.append(tab['tabName'])

for x in range(self.tab_main.count() - 1, 0, -1):
if self.tab_main.widget(x).objectName() not in tabs_to_show:
tools_qt.remove_tab(self.tab_main, self.tab_main.widget(x).objectName())
elif new_feature and self.tab_main.widget(x).objectName() != 'tab_data':
tools_qt.enable_tab_by_tab_name(self.tab_main, self.tab_main.widget(x).objectName(), False)

# Actions
self._get_actions()
Expand Down Expand Up @@ -1619,6 +1623,10 @@ def _manage_edition(self, dialog, action_edit, fid, new_feature=None, generic=Fa
self._manage_docker_close()
else:
tools_gw.close_dialog(dialog)
if new_feature:
for tab in self.visible_tabs:
tools_qt.enable_tab_by_tab_name(self.tab_main, tab['tabName'], True)
self._reload_epa_tab(dialog)
self._reset_my_json()
else:
tools_qt.set_action_checked(action_edit, True)
Expand Down Expand Up @@ -1929,8 +1937,10 @@ def _accept(self, dialog, complet_result, _json, p_widget=None, clear_json=False
self._manage_docker_close()
else:
tools_gw.close_dialog(dialog)
QgsProject.instance().blockSignals(False)
return None

QgsProject.instance().blockSignals(False)
return True


Expand Down Expand Up @@ -2749,8 +2759,8 @@ def _fill_tbl(self, complet_result, dialog, widgetname, linkedobject, filter_fie
short_name = field['widgetname'].replace(f"tab_{tab_name}_", "", 1)
widget = tools_gw.add_tableview_header(widget, field)
widget = tools_gw.fill_tableview_rows(widget, field)
widget = tools_gw.set_tablemodel_config(dialog, widget, short_name, 1, True)
tools_qt.set_tableview_config(widget, edit_triggers=QTableView.DoubleClicked)
tools_qt.set_tableview_config(widget, edit_triggers=QTableView.DoubleClicked, sectionResizeMode=0)
widget = tools_gw.set_tablemodel_config(dialog, widget, linkedobject, 1, True)
if 'tab_epa' in widgetname:
model = widget.model()
tbl_upsert = widget.property('widgetcontrols').get('tableUpsert')
Expand Down
5 changes: 4 additions & 1 deletion core/shared/nonvisual.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ def _manage_tabs_changed(self):
chk_active_visible, btn_print_visible = visibility_settings.get(tab_name, default_visibility)

self.manager_dlg.chk_active.setVisible(chk_active_visible)
self.manager_dlg.btn_print.setVisible(btn_print_visible)
if btn_print_visible and global_vars.project_type == 'ud':
self.manager_dlg.btn_print.setVisible(btn_print_visible)
else:
self.manager_dlg.btn_print.setVisible(False)


def _get_nonvisual_object(self, tbl_view, function_name):
Expand Down
5 changes: 5 additions & 0 deletions core/shared/psector.py
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,11 @@ def charge_psector(self, qtbl_psm):
if tools_os.set_boolean(keep_open_form, False) is not True:
tools_gw.close_dialog(self.dlg_psector_mng)

# put psector on selector_psector
sql = f"DELETE FROM selector_psector WHERE psector_id = {psector_id} AND cur_user = current_user;" \
f"INSERT INTO selector_psector (psector_id, cur_user) VALUES ({psector_id}, current_user);"
tools_db.execute_sql(sql)

# Open form
self.master_new_psector(psector_id)

Expand Down
1 change: 1 addition & 0 deletions core/threads/toolbox_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def finished(self, result):
tools_qt.show_exception_message(msg=lib_vars.session_vars['last_error_msg'])
elif result:
tools_gw.fill_tab_log(self.dialog, self.json_result['body']['data'], True, True, 1, False, False)
self.dialog.btn_run.setEnabled(False)
# If sql function return null
elif result is False:
msg = f"Database returned null. Check postgres function 'gw_fct_getinfofromid'"
Expand Down
2 changes: 2 additions & 0 deletions core/toolbars/basic/info_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ def _get_layers_from_coordinates(self, point, rb_list, tab_type=None):
action_valve.hovered.connect(partial(self._reset_rubber_bands))
main_menu.addAction(action_valve)
main_menu.addSeparator()

main_menu.aboutToHide.connect(self._reset_rubber_bands)
main_menu.exec_(click_point)


Expand Down
2 changes: 2 additions & 0 deletions core/toolbars/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
from .plan.psector_button import GwPsectorButton
from .plan.psector_manager_button import GwPsectorManagerButton
from .plan.price_manager_button import GwPriceManagerButton
from .plan.netscenario_manager_btn import GwNetscenarioManagerButton

# Utilities
from .utilities.toolbox_btn import GwToolBoxButton
Expand All @@ -60,6 +61,7 @@
from .utilities.print_btn import GwPrintButton
from .utilities.project_check_btn import GwProjectCheckButton
from .utilities.workspace_manager_btn import GwWorkspaceManagerButton
from .utilities.utils_manager_btn import GwUtilsManagerButton

# ToC
from .toc.add_child_layer_button import GwAddChildLayerButton
Expand Down
37 changes: 37 additions & 0 deletions core/toolbars/epa/go2epa_manager_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def _manage_go2epa(self):
self.dlg_manager.btn_set_corporate.setEnabled(False)
if self.project_type != 'ws':
self.dlg_manager.btn_set_corporate.setVisible(False)
self.dlg_manager.btn_archive.setVisible(False)

# Fill combo box and table view
# self._fill_combo_result_id()
Expand All @@ -57,6 +58,8 @@ def _manage_go2epa(self):
model.flags = lambda index: self.flags(index, model)

# Set signals
self.dlg_manager.btn_archive.clicked.connect(partial(self._set_rpt_archived, self.dlg_manager.tbl_rpt_cat_result,
'result_id'))
self.dlg_manager.btn_set_corporate.clicked.connect(partial(self._epa2data, self.dlg_manager.tbl_rpt_cat_result,
'result_id'))
self.dlg_manager.btn_delete.clicked.connect(partial(self._multi_rows_delete, self.dlg_manager.tbl_rpt_cat_result,
Expand Down Expand Up @@ -261,6 +264,40 @@ def _multi_rows_delete(self, widget, table_name, column_id):
self._fill_manager_table(tools_qt.get_text(self.dlg_manager, 'txt_result_id'))


def _set_rpt_archived(self, widget, column_id):
""" Call gw_fct_set_rpt_archived with selected result_id
:param QTableView widget: origin
:param table_name: table origin
:param column_id: Refers to the id of the source table
"""

# Get selected rows
selected_list = widget.selectionModel().selectedRows()
if len(selected_list) == 0:
message = "Any record selected"
tools_qgis.show_warning(message, dialog=self.dlg_manager)
return

row = selected_list[0].row()
col = tools_qt.get_col_index_by_col_name(widget, str(column_id))
result_id = widget.model().index(row, col).data()

# check corporate
extras = f'"result_id":"{result_id}"'
body = tools_gw.create_body(extras=extras)
result = tools_gw.execute_procedure('gw_fct_set_rpt_archived', body)

if not result or result.get('status') != 'Accepted':
message = "gw_fct_set_rpt_archived execution failed. See logs for more details..."
tools_qgis.show_warning(message, dialog=self.dlg_manager)
return

message = "Set rpt archived execution successful."
tools_qgis.show_info(message, dialog=self.dlg_manager)
# Refresh table
self._fill_manager_table()


def _epa2data(self, widget, column_id):
""" Delete selected elements of the table
:param QTableView widget: origin
Expand Down
Loading

0 comments on commit a5e54c5

Please sign in to comment.