(self)
| 21 | self.savedStateCheckChanges = None |
| 22 | |
| 23 | def Do(self): |
| 24 | pyfalog.debug('Doing removal of projected fit {} for fit {}'.format(self.projectedFitID, self.fitID)) |
| 25 | sFit = Fit.getInstance() |
| 26 | fit = sFit.getFit(self.fitID) |
| 27 | projectedFit = sFit.getFit(self.projectedFitID, projected=True) |
| 28 | |
| 29 | # Can be removed by the time we're redoing it |
| 30 | if projectedFit is None: |
| 31 | pyfalog.debug('Projected fit is not available') |
| 32 | return False |
| 33 | projectionInfo = projectedFit.getProjectionInfo(self.fitID) |
| 34 | if not projectionInfo: |
| 35 | pyfalog.warning('Fit projection info is not available') |
| 36 | return False |
| 37 | |
| 38 | self.savedState = projectionInfo.active |
| 39 | self.savedAmount = projectionInfo.amount |
| 40 | |
| 41 | remainingAmount = projectionInfo.amount - self.amount |
| 42 | |
| 43 | # Change amount if more than 0 remaining, remove otherwise |
| 44 | if remainingAmount > 0: |
| 45 | from .changeAmount import CalcChangeProjectedFitAmountCommand |
| 46 | self.changeAmountCommand = CalcChangeProjectedFitAmountCommand( |
| 47 | fitID=self.fitID, |
| 48 | projectedFitID=self.projectedFitID, |
| 49 | amount=remainingAmount) |
| 50 | if not self.changeAmountCommand.Do(): |
| 51 | return False |
| 52 | sFit.recalc(fit) |
| 53 | self.savedStateCheckChanges = sFit.checkStates(fit, None) |
| 54 | return True |
| 55 | else: |
| 56 | self.changeAmountCommand = None |
| 57 | if projectedFit.ID not in fit.projectedFitDict: |
| 58 | pyfalog.warning('Unable to find projected fit in projected dict') |
| 59 | return False |
| 60 | del fit.projectedFitDict[projectedFit.ID] |
| 61 | sFit.recalc(fit) |
| 62 | self.savedStateCheckChanges = sFit.checkStates(fit, None) |
| 63 | return True |
| 64 | |
| 65 | def Undo(self): |
| 66 | pyfalog.debug('Undoing removal of projected fit {} for fit {}'.format(self.projectedFitID, self.fitID)) |
no test coverage detected