mirror of https://gitlab.com/pamhyr/pamhyr2
WeatherParameters: deleted variable not useful in default params
parent
868215705c
commit
b5ae352af5
|
|
@ -176,7 +176,7 @@ class WeatherParametersDefault(SQLSubModel):
|
|||
return new
|
||||
|
||||
table = execute(
|
||||
"SELECT pamhyr_id, deleted, type, value, scenario " +
|
||||
"SELECT pamhyr_id, type, value, scenario " +
|
||||
"FROM weather_parameters_default " +
|
||||
f"WHERE scenario = {scenario.id} " +
|
||||
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) "
|
||||
|
|
@ -186,7 +186,6 @@ class WeatherParametersDefault(SQLSubModel):
|
|||
it = iter(row)
|
||||
|
||||
pid = next(it)
|
||||
deleted = next(it)
|
||||
type = next(it)
|
||||
value = next(it)
|
||||
owner_scenario = next(it)
|
||||
|
|
@ -198,8 +197,6 @@ class WeatherParametersDefault(SQLSubModel):
|
|||
status=status,
|
||||
owner_scenario=owner_scenario
|
||||
)
|
||||
if deleted:
|
||||
wp_default.set_as_deleted()
|
||||
|
||||
loaded.add(pid)
|
||||
new.append(wp_default)
|
||||
|
|
@ -217,10 +214,9 @@ class WeatherParametersDefault(SQLSubModel):
|
|||
execute(
|
||||
"INSERT INTO " +
|
||||
"weather_parameters_default(" +
|
||||
"pamhyr_id, deleted, type, value, scenario) " +
|
||||
"pamhyr_id, type, value, scenario) " +
|
||||
"VALUES (" +
|
||||
f"{self.id}, {self._db_format(self.is_deleted())}, " +
|
||||
f"'{self._db_format(self._type)}', {self._value}, " +
|
||||
f"{self.id}, '{self._db_format(self._type)}', {self._value}, " +
|
||||
f"{self._status.scenario_id}" +
|
||||
")"
|
||||
)
|
||||
|
|
@ -286,7 +282,6 @@ class WeatherParameters(SQLSubModel):
|
|||
execute(f"""
|
||||
CREATE TABLE weather_parameters_default{ext}(
|
||||
{cls.create_db_add_pamhyr_id()},
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
type TEXT NOT NULL,
|
||||
value FLOAT NOT NULL,
|
||||
{Scenario.create_db_add_scenario()},
|
||||
|
|
@ -348,7 +343,6 @@ class WeatherParameters(SQLSubModel):
|
|||
execute(f"""
|
||||
CREATE TABLE weather_parameters_default(
|
||||
{cls.create_db_add_pamhyr_id()},
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
type TEXT NOT NULL,
|
||||
value FLOAT NOT NULL,
|
||||
{Scenario.create_db_add_scenario()},
|
||||
|
|
|
|||
|
|
@ -152,12 +152,7 @@ class WeatherParametersList(PamhyrModelList):
|
|||
|
||||
@property
|
||||
def default(self):
|
||||
return list(
|
||||
filter(
|
||||
lambda el: not el.is_deleted(),
|
||||
self._default
|
||||
)
|
||||
)
|
||||
return self._default.copy()
|
||||
|
||||
def default_for_type(self, type):
|
||||
for wp_default in self.default:
|
||||
|
|
|
|||
Loading…
Reference in New Issue