Restore removed dummies on all commands which can deal with t3c subsystems

This commit is contained in:
DarkPhoenix
2019-04-30 13:50:10 +03:00
parent fa2bceaff9
commit 63a599ca85
13 changed files with 71 additions and 43 deletions

View File

@@ -3,7 +3,7 @@ from logbook import Logger
import eos.db
from eos.const import FittingSlot
from gui.fitCommands.helpers import ModuleInfo, restoreCheckedStates, restoreRemovedDummies
from gui.fitCommands.helpers import ModuleInfo, restoreCheckedStates
from service.fit import Fit
@@ -19,7 +19,6 @@ class CalcRemoveLocalModulesCommand(wx.Command):
self.commit = commit
self.savedSubInfos = None
self.savedModInfos = None
self.savedRemovedDummies = None
self.savedStateCheckChanges = None
def Do(self):
@@ -44,7 +43,7 @@ class CalcRemoveLocalModulesCommand(wx.Command):
# Need to flush because checkStates sometimes relies on module->fit
# relationship via .owner attribute, which is handled by SQLAlchemy
eos.db.flush()
self.savedRemovedDummies = sFit.recalc(fit)
sFit.recalc(fit)
self.savedStateCheckChanges = sFit.checkStates(fit, None)
if self.commit:
eos.db.commit()
@@ -70,7 +69,6 @@ class CalcRemoveLocalModulesCommand(wx.Command):
results.append(cmd.Do())
if not any(results):
return False
restoreRemovedDummies(fit, self.savedRemovedDummies)
restoreCheckedStates(fit, self.savedStateCheckChanges)
if self.commit:
eos.db.commit()

View File

@@ -3,7 +3,7 @@ from logbook import Logger
import eos.db
from eos.exception import HandledListActionError
from gui.fitCommands.helpers import ModuleInfo, restoreCheckedStates, restoreRemovedDummies, stateLimit
from gui.fitCommands.helpers import ModuleInfo, restoreCheckedStates, stateLimit
from service.fit import Fit
@@ -21,7 +21,6 @@ class CalcReplaceLocalModuleCommand(wx.Command):
self.unloadInvalidCharges = unloadInvalidCharges
self.commit = commit
self.savedStateCheckChanges = None
self.savedRemovedDummies = None
self.unloadedCharge = None
def Do(self):
@@ -62,7 +61,7 @@ class CalcReplaceLocalModuleCommand(wx.Command):
# Need to flush because checkStates sometimes relies on module->fit
# relationship via .owner attribute, which is handled by SQLAlchemy
eos.db.flush()
self.savedRemovedDummies = sFit.recalc(fit)
sFit.recalc(fit)
self.savedStateCheckChanges = sFit.checkStates(fit, newMod)
if self.commit:
eos.db.commit()
@@ -97,7 +96,6 @@ class CalcReplaceLocalModuleCommand(wx.Command):
pyfalog.warning('Failed to replace in list')
self.Do()
return False
restoreRemovedDummies(fit, self.savedRemovedDummies)
restoreCheckedStates(fit, self.savedStateCheckChanges)
if self.commit:
eos.db.commit()