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