AddFile: Add deleted flags.

This commit is contained in:
Pierre-Antoine Rouby committed 2024-08-27 17:08:40 +02:00
1 parent 8c99268bb8
commit ac32995e01
5 files changed
+394 -10

No files matched your search

+48
View File
@@ -162,6 +162,17 @@ class SQLSubModel(PamhyrID):
super(SQLSubModel, self).__init__(id)
self._status = status
# Deletion status of the model object. This status MUST be set
# to True if an object that exists in a parent scenario is
# deleted in current scenario.
self._deleted = False
# The 'owner_scenario' is the id of the scenario to which the
# object belongs. This id CAN be different to current
# scenario, but in case of object modification, this id MUST
# be set to current scenario id. (This action is made in
# 'modified' method.)
self._owner_scenario = 0
if owner_scenario == -1:
if status is not None:
@@ -170,12 +181,49 @@ class SQLSubModel(PamhyrID):
self._owner_scenario = owner_scenario
def must_be_saved(self):
"""Return True if this object MUST be save in the save file.
Returns:
True if this object MUST be save, otherelse False
"""
return self._owner_scenario == self._status.scenario_id
def modified(self):
"""Set study status to modified and update the object
owner_scenario to current scenario
Returns:
Nothing
"""
self._owner_scenario = self._status.scenario_id
self._status.modified()
def is_deleted(self):
"""This object is deleted?
Returns:
True if this object is deleted, otherelse False
"""
return self._deleted
def set_as_deleted(self):
"""Set object deleted flag to True.
Returns:
Nothing
"""
self._deleted = True
self.modified()
def set_as_not_deleted(self):
"""Set object deleted flag to False.
Returns:
Nothing
"""
self._deleted = False
self.modified()
def _db_format(self, value):
# Replace ''' by ''' to preserve SQL injection
if type(value) is str: