Model: Tools: Prepare scenario duplication.

scenarios
Pierre-Antoine 2025-09-02 17:20:09 +02:00
parent 2916afb974
commit 1e2a123693
4 changed files with 45 additions and 1 deletions

View File

@ -202,7 +202,6 @@ class SQLSubModel(PamhyrID):
self._owner_scenario = self._status.scenario_id self._owner_scenario = self._status.scenario_id
self._status.modified() self._status.modified()
def set_owner_scenario_if(self, predicate): def set_owner_scenario_if(self, predicate):
"""Set study status the object owner_scenario to current """Set study status the object owner_scenario to current
scenario if predicate(scenario_id) is true scenario if predicate(scenario_id) is true

View File

@ -82,5 +82,20 @@ class PamhyrModelDict(SQLSubModel):
self.set(key, new) self.set(key, new)
return new return new
def rec_set_owner_scenario_if(self, predicate):
"""Set study status the object owner_scenario to current
scenario if predicate(scenario_id) is true
Args:
predicate: Function predicate on owner_scenario id
Returns:
Nothing
"""
self.set_owner_scenario_if(predicate)
for k in self._lst:
self._dict[key].set_owner_scenario_if(predicate)
def new(self, key): def new(self, key):
raise NotImplementedMethodeError(self, self.new) raise NotImplementedMethodeError(self, self.new)

View File

@ -85,6 +85,21 @@ class PamhyrModelList(SQLSubModel):
if self._status is not None: if self._status is not None:
self._status.modified() self._status.modified()
def rec_set_owner_scenario_if(self, predicate):
"""Set study status the object owner_scenario to current
scenario if predicate(scenario_id) is true
Args:
predicate: Function predicate on owner_scenario id
Returns:
Nothing
"""
self.set_owner_scenario_if(predicate)
for el in self._lst:
el.set_owner_scenario_if(predicate)
def new(self, index): def new(self, index):
"""Create new elements and add it to list """Create new elements and add it to list

View File

@ -90,6 +90,21 @@ class PamhyrModelList(SQLSubModel):
if self._status is not None: if self._status is not None:
self._status.modified() self._status.modified()
def rec_set_owner_scenario_if(self, predicate):
"""Set study status the object owner_scenario to current
scenario if predicate(scenario_id) is true
Args:
predicate: Function predicate on owner_scenario id
Returns:
Nothing
"""
self.set_owner_scenario_if(predicate)
for el in self._lst:
el.set_owner_scenario_if(predicate)
def new(self, index): def new(self, index):
"""Create new elements and add it to list """Create new elements and add it to list