mirror of https://gitlab.com/pamhyr/pamhyr2
work 3
parent
f53289ef1b
commit
13b954d580
|
|
@ -51,6 +51,34 @@ class OutputKpAdists(SQLSubModel):
|
|||
LateralContribution._id_cnt = max(
|
||||
LateralContribution._id_cnt + 1, self.id)
|
||||
|
||||
@property
|
||||
def reach(self):
|
||||
return self._reach
|
||||
|
||||
@reach.setter
|
||||
def reach(self, reach_id):
|
||||
self._reach = reach_id
|
||||
self._status.modified()
|
||||
|
||||
@property
|
||||
def kp(self):
|
||||
return self._kp
|
||||
|
||||
@kp.setter
|
||||
def kp(self, profile_id):
|
||||
self._kp = profile_id
|
||||
self._status.modified()
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
return self._title
|
||||
|
||||
@title.setter
|
||||
def title(self, title):
|
||||
self._title = title
|
||||
self._status.modified()
|
||||
|
||||
|
||||
@classmethod
|
||||
def _db_create(cls, execute):
|
||||
execute("""
|
||||
|
|
@ -98,6 +126,22 @@ class OutputKpAdists(SQLSubModel):
|
|||
|
||||
return new
|
||||
|
||||
def _db_save(self, execute, data=None):
|
||||
|
||||
sql = (
|
||||
"INSERT INTO " +
|
||||
"OutputKpAdists(id, reach, kp, title " +
|
||||
"VALUES (" +
|
||||
f"{self.id}, {self._reach}, " +
|
||||
f"{self._kp}, '{self._db_format(self._title)}" +
|
||||
")"
|
||||
)
|
||||
|
||||
execute(sql)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
# OutputKpListAdists.py -- Pamhyr
|
||||
# Copyright (C) 2024 INRAE
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from tools import trace, timer
|
||||
|
||||
from Model.Except import NotImplementedMethodeError
|
||||
from Model.Tools.PamhyrList import PamhyrModelList
|
||||
from Model.OutputKpAdists.OutputKpAdists import OutputKpAdists
|
||||
|
||||
|
||||
class OutputKpAdistsList(PamhyrModelList):
|
||||
_sub_classes = [OutputKpAdistsList]
|
||||
|
||||
@classmethod
|
||||
def _db_load(cls, execute, data=None):
|
||||
new = cls(status=data["status"])
|
||||
|
||||
new._lst = OutputKpAdists._db_load(execute, data)
|
||||
|
||||
return new
|
||||
|
||||
def _db_save(self, execute, data=None):
|
||||
ok = True
|
||||
|
||||
# Delete previous data
|
||||
execute("DELETE FROM OutputKpAdists")
|
||||
|
||||
for sl in self._lst:
|
||||
ok &= sl._db_save(execute, data)
|
||||
|
||||
return ok
|
||||
|
||||
@property
|
||||
def OutputKp_List(self):
|
||||
return self.lst
|
||||
|
||||
def new(self, index):
|
||||
n = OutputKpAdists(status=self._status)
|
||||
self.insert(index, n)
|
||||
self._status.modified()
|
||||
return n
|
||||
Loading…
Reference in New Issue