Skip to content

Commit 15afb1e

Browse files
committed
Merge branch 'dev-3.6' into master-3.6
2 parents 937d156 + 5e272c0 commit 15afb1e

File tree

3 files changed

+19
-47
lines changed

3 files changed

+19
-47
lines changed

core/shared/mincut_tools.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,19 @@ def delete_mincut(**kwargs):
239239
title = "Delete mincut"
240240

241241
# Check for mincuts not allowed to be deleted
242-
sql = (f"SELECT * FROM {table_name}"
243-
f" WHERE {column_id} IN ({list_id}) AND (anl_user != current_user OR mincut_state != 0)")
244-
rows = tools_db.execute_returning(sql, show_exception=False)
245-
if rows:
246-
message = "You can't delete these mincuts because they aren't planified \n" \
247-
"or they were created by another user:"
248-
tools_qt.show_info_box(message, title, inf_text)
249-
return
242+
row = tools_gw.get_config_value('om_mincut_settings', table='config_param_system')
243+
om_mincut_settings = row[0] if row else None
244+
if om_mincut_settings:
245+
om_mincut_settings = json.loads(om_mincut_settings)
246+
if (om_mincut_settings is None or not om_mincut_settings.get('deleteUsers') or om_mincut_settings['deleteUsers'] == 'creator'):
247+
sql = (f"SELECT * FROM {table_name}"
248+
f" WHERE {column_id} IN ({list_id}) AND (anl_user != current_user OR mincut_state != 0)")
249+
rows = tools_db.execute_returning(sql, show_exception=False)
250+
if rows:
251+
message = "You can't delete these mincuts because they aren't planified \n" \
252+
"or they were created by another user:"
253+
tools_qt.show_info_box(message, title, inf_text)
254+
return
250255

251256
answer = tools_qt.show_question(message, title, inf_text)
252257
if answer:

core/shared/search.py

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ def open_search(self, dlg_search, dlg_mincut=None):
107107
widget = self._set_typeahead_completer(widget, completer)
108108
self.lineedit_list.append(widget)
109109
elif field['widgettype'] == 'combo':
110-
widget = self._add_combobox(field)
110+
widget = tools_gw.add_combo(field)
111+
widget.currentIndexChanged.connect(partial(self._clear_lineedits))
111112
elif field['widgettype'] == 'check':
112113
kwargs = {"dialog": self.dlg_search, "field": field}
113114
widget = tools_gw.add_checkbox(**kwargs)
@@ -183,7 +184,7 @@ def export_to_csv(self, dialog, qtable_1=None, qtable_2=None, path=None):
183184

184185

185186
def refresh_tab(self, tab_name=None):
186-
187+
187188
if tab_name:
188189
form = f'"singleTab":"{tab_name}"'
189190
else:
@@ -203,8 +204,7 @@ def refresh_tab(self, tab_name=None):
203204
try:
204205
if field['widgettype'] == 'combo':
205206
widget = main_tab.findChild(QComboBox, field['widgetname'])
206-
list_items = self._get_list_items(widget, field)
207-
tools_qt.fill_combo_values(widget, list_items)
207+
tools_gw.fill_combo(widget, field)
208208
except Exception:
209209
msg = f"key 'comboIds' or/and comboNames not found WHERE columname='{field['columnname']}' AND " \
210210
f"widgetname='{field['widgetname']}' AND widgettype='{field['widgettype']}'"
@@ -481,46 +481,13 @@ def _clear_line_edit_add(self, line_list):
481481
line_edit_add.blockSignals(False)
482482

483483

484-
def _add_combobox(self, field):
485-
486-
widget = QComboBox()
487-
widget.setObjectName(field['widgetname'])
488-
widget.setProperty('columnname', field['columnname'])
489-
list_items = self._get_list_items(widget, field)
490-
tools_qt.fill_combo_values(widget, list_items)
491-
tools_qt.set_combo_value(widget, field.get('selectedId'), 0, add_new=False)
492-
# noinspection PyUnresolvedReferences
493-
widget.currentIndexChanged.connect(partial(self._clear_lineedits))
494-
495-
return widget
496-
497-
498484
def _clear_lineedits(self):
499485

500486
# Clear all lineedit widgets from search tabs
501487
for widget in self.lineedit_list:
502488
tools_qt.set_widget_text(self.dlg_search, widget, '')
503489

504490

505-
def _get_list_items(self, widget, field):
506-
507-
# Generate list of items to add into combo
508-
widget.blockSignals(True)
509-
widget.clear()
510-
widget.blockSignals(False)
511-
list_items = []
512-
comboIds = field.get('comboIds')
513-
comboNames = field.get('comboNames')
514-
comboFeature = field.get('comboFeature')
515-
if None not in (comboIds, comboNames):
516-
for i in range(0, len(comboIds)):
517-
if comboFeature:
518-
elem = [comboIds[i], comboNames[i], comboFeature[i]]
519-
else:
520-
elem = [comboIds[i], comboNames[i]]
521-
list_items.append(elem)
522-
return list_items
523-
524491
def _open_hydrometer_dialog(self, table_name=None, feature_id=None, sys_feature_type_id=None, basic_search_hydrometer=False, feature_type=None):
525492
if basic_search_hydrometer:
526493
self.customForm = GwInfo(tab_type='data')

metadata.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ qgisMinimumVersion=3.22
44
qgisMaximumVersion=3.40
55
description=Plugin to manage water networks (water supply, sewerage and urban drainage) using QGIS and PostGIS-PostgreSQL
66
about=Disclaimer: This plugin is released using the open source GNU-GPL3 license. Although a reasonable effort has been made to assure that the results obtained are correct, some of the capabilities provided by Giswater are experimental, therefore the development team and the Giswater Association are not responsible and assume no liability whatsoever for any results or any use made of the results obtained from the program, nor for any damages or litigation that result from the use of these programs for any purpose. Third-Party Libraries: WNTR. More information on their licenses can be found on the repository README file.
7-
version=3.6.020
7+
version=3.6.021
88
author=David Erill, Natasa Cica, Nestor Ibañez, Barbara Rzepka, Sergi Muñoz, Josep Lluís Sala, Edgar Fusté, Albert Bofill, Sergi Maspons, Lia Bertran, Abel García Juanes, Maria Guzmán, Jordi Blanch, Xavier Torret, Daniel Marín, Ferran Martínez, Nico Pérez, Pablo Marques, Arnau Torret, Namrata Karki, Arnau Urgeles, Oscar Pueyo
99

10-
Changelog=Version 3.6.020
10+
Changelog=Version 3.6.021
1111

1212

1313
tags= giswater, water networks, sewerage, urban drainage, EPANET, SWMM

0 commit comments

Comments
 (0)