mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-29 19:10:42 +01:00
Merge branch 'dev_dylan' into scenarios
This commit is contained in:
commit
c44597dfbd
3 files changed
+22
-1
No files matched your search
@@ -34,6 +34,7 @@ class StudyStatus(object):
|
||||
self._status = Status.EDIT
|
||||
self._scenario = scenario
|
||||
self._saved = True
|
||||
self._loading = False
|
||||
|
||||
@property
|
||||
def scenario_id(self):
|
||||
@@ -86,6 +87,15 @@ class StudyStatus(object):
|
||||
def is_saved(self):
|
||||
return self._saved
|
||||
|
||||
def is_loading(self):
|
||||
return self._loading
|
||||
|
||||
def start_loading(self):
|
||||
self._loading = True
|
||||
|
||||
def stop_loading(self):
|
||||
self._loading = False
|
||||
|
||||
def save(self):
|
||||
logger.debug("model status set as saved")
|
||||
self._saved = True
|
||||
@@ -97,6 +107,9 @@ class StudyStatus(object):
|
||||
self._saved = True
|
||||
|
||||
def modified(self):
|
||||
if self._loading:
|
||||
return
|
||||
|
||||
if self._saved:
|
||||
self.version += 1
|
||||
|
||||
|
||||
+5
-1
@@ -573,16 +573,20 @@ class Study(SQLModel):
|
||||
"scenario": scenario
|
||||
}
|
||||
|
||||
self.status.start_loading()
|
||||
try:
|
||||
# Load river data
|
||||
river = River._db_load(
|
||||
sql_exec, data=data
|
||||
)
|
||||
data["study"] = self
|
||||
river._db_load_results(sql_exec, data=data)
|
||||
finally:
|
||||
self.status.stop_loading()
|
||||
self.status.scenario = old_scenario
|
||||
|
||||
# FIXME: Disable scenario cache to save memory usage
|
||||
# self._river_scenario_cache[scenario] = river
|
||||
self.status.scenario = old_scenario
|
||||
|
||||
return river
|
||||
|
||||
|
||||
@@ -202,6 +202,8 @@ class SQLSubModel(PamhyrID):
|
||||
"""
|
||||
if self._status is None:
|
||||
return
|
||||
if self._status.is_loading():
|
||||
return
|
||||
|
||||
self._owner_scenario = self._status.scenario_id
|
||||
self._status.modified()
|
||||
@@ -218,6 +220,8 @@ class SQLSubModel(PamhyrID):
|
||||
"""
|
||||
if self._status is None:
|
||||
return
|
||||
if self._status.is_loading():
|
||||
return
|
||||
|
||||
self._owner_scenario = self._status.scenario_id
|
||||
self._status.modified()
|
||||
|
||||
Reference in new issue
Block a user