mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
debug add function and save/load in db for edit LCAdisTS window
This commit is contained in:
1 parent
102702e1df
commit
30e34b6847
4 files changed
+68
-30
No files matched your search
@@ -135,7 +135,7 @@ class Data(SQLSubModel):
|
||||
lca = data["lca"]
|
||||
|
||||
table = execute(
|
||||
"SELECT pamhyr_id, deleted, data0, data1 " +
|
||||
"SELECT pamhyr_id, deleted, data0, data1, scenario " +
|
||||
"FROM lateral_contribution_data_adists " +
|
||||
f"WHERE scenario = {scenario.id} " +
|
||||
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) " +
|
||||
@@ -152,16 +152,16 @@ class Data(SQLSubModel):
|
||||
data1 = next(it)
|
||||
owner_scenario = next(it)
|
||||
|
||||
data = cls(
|
||||
lc = cls(
|
||||
data0, data1,
|
||||
id=pid, status=status,
|
||||
owner_scenario=owner_scenario
|
||||
)
|
||||
if deleted:
|
||||
data.set_as_deleted()
|
||||
lc.set_as_deleted()
|
||||
|
||||
loaded.add(pid)
|
||||
new.append(data)
|
||||
new.append(lc)
|
||||
|
||||
data["scenario"] = scenario.parent
|
||||
new += cls._db_load(execute, data)
|
||||
@@ -177,7 +177,7 @@ class Data(SQLSubModel):
|
||||
|
||||
execute(
|
||||
"INSERT INTO " +
|
||||
"lateral_contribution_adists(pamhyr_id, deleted," +
|
||||
"lateral_contribution_data_adists(pamhyr_id, deleted," +
|
||||
"data0, data1, lca, scenario) " +
|
||||
"VALUES (" +
|
||||
f"{self.id}, {self._db_format(self.is_deleted())}, " +
|
||||
@@ -384,6 +384,8 @@ class LateralContributionAdisTS(SQLSubModel):
|
||||
")"
|
||||
)
|
||||
|
||||
data["lca"] = self
|
||||
|
||||
ind = 0
|
||||
for d in self._data:
|
||||
data["ind"] = ind
|
||||
@@ -473,3 +475,57 @@ class LateralContributionAdisTS(SQLSubModel):
|
||||
def end_rk(self, end_rk):
|
||||
self._end_rk = end_rk
|
||||
self.modified()
|
||||
|
||||
@property
|
||||
def _default_0(self):
|
||||
return self._types[0](0)
|
||||
|
||||
@property
|
||||
def _default_1(self):
|
||||
return self._types[1](0.0)
|
||||
|
||||
def add(self, index: int):
|
||||
value = Data(self._default_0, self._default_1, status=self._status)
|
||||
self._data.insert(index, value)
|
||||
self.modified()
|
||||
return value
|
||||
|
||||
def insert(self, index: int, data: Data):
|
||||
self._data.insert(index, data)
|
||||
self.modified()
|
||||
|
||||
def delete_i(self, indexes):
|
||||
self._data = list(
|
||||
map(
|
||||
lambda e: e[1],
|
||||
filter(
|
||||
lambda e: e[0] not in indexes,
|
||||
enumerate(self.data)
|
||||
)
|
||||
)
|
||||
)
|
||||
self.modified()
|
||||
|
||||
def index(self, bc):
|
||||
self._data.index(bc)
|
||||
|
||||
def get_i(self, index: int):
|
||||
return self._data[index]
|
||||
|
||||
def get_range(self, _range):
|
||||
lst = []
|
||||
for r in _range:
|
||||
lst.append(r)
|
||||
return lst
|
||||
|
||||
def _set_i_c_v(self, index: int, column: int, value):
|
||||
v = self._data[index]
|
||||
v[column] = self._types[column](value)
|
||||
self._data[index] = v
|
||||
self.modified()
|
||||
|
||||
def set_i_0(self, index: int, value):
|
||||
self._set_i_c_v(index, 0, value)
|
||||
|
||||
def set_i_1(self, index: int, value):
|
||||
self._set_i_c_v(index, 1, value)
|
||||
Reference in new issue
Block a user