mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Disable profiles: security to prevent the disable of a profile associated with data (initial conditions, structures, lateral conditions, weather params, init. cond. temperature)
This commit is contained in:
1 parent
8978cc3482
commit
944f99f14b
4 files changed
+163
-1
No files matched your search
@@ -573,6 +573,49 @@ class GeometryWindow(PamhyrWindow):
|
||||
if len(rows) == 0:
|
||||
return
|
||||
|
||||
if not enabled:
|
||||
blocked = []
|
||||
for row in rows:
|
||||
profile = self._reach.profile(row)
|
||||
dependencies = self._study.river.profile_dependencies(profile)
|
||||
if len(dependencies) != 0:
|
||||
blocked.append((profile, dependencies))
|
||||
|
||||
if len(blocked) != 0:
|
||||
details = []
|
||||
for profile, dependencies in blocked:
|
||||
details.append(f"{profile.name}:")
|
||||
for dependency in dependencies:
|
||||
item = dependency["item"]
|
||||
if dependency["kind"] == "weather_parameter":
|
||||
name = self._trad.get_dict(
|
||||
"weather_parameter_types"
|
||||
).get(item.type, item.type)
|
||||
else:
|
||||
name = getattr(item, "name", "")
|
||||
if name == "":
|
||||
name = self._trad[dependency["kind"]]
|
||||
details.append(
|
||||
" - " +
|
||||
self._trad["profile_dependency"].format(
|
||||
kind=self._trad[dependency["kind"]],
|
||||
name=name,
|
||||
association=self._trad[
|
||||
dependency["association"]
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
self._set_checkbox_state()
|
||||
self.message_box(
|
||||
self._trad["profile_disable_blocked"],
|
||||
self._trad["profile_disable_blocked_info"].format(
|
||||
dependencies="\n".join(details)
|
||||
),
|
||||
window_title=self._trad["warning"],
|
||||
)
|
||||
return
|
||||
|
||||
self._checkbox.setTristate(False)
|
||||
self._table.enabled(rows, enabled)
|
||||
|
||||
|
||||
Reference in new issue
Block a user