def execute_action(self, action: WorkflowActionModel, meta: Meta): if self.status != action.fromStatus: raise MethodNotAllowedException( message="Workflow action is not allowed.", code=MESSAGE_CODE_WORKFLOW_ACTION_NOT_ALLOWED) else: self.status = action.toStatus self.latestLogId = WorkflowInstanceLog.create( workflowInstanceId=self.workflowInstanceId, status=action.toStatus, workflowActionId=action.workflowActionId, metaId=meta.metaId, proofId=self.proofId).workflowInstanceLogId self.proof.close() # proof is replaced only for WORKFLOW_ACTION_TYPE_REQUEST_CHANGES if action.actionType == WORKFLOW_ACTION_TYPE_REQUEST_CHANGES: self.proofId = Proof.create().proofId # For all the other actions, the proof is cloned. else: self.proofId = self.proof.clone().proofId db.session.add(self) db.session.flush() return self
def create(cls, workflowId, status): workflow_action = cls(workflowInstanceId=History.create().historyId, proofId=Proof.create().proofId, workflowId=workflowId, status=status) db.session.add(workflow_action) db.session.flush() return workflow_action
def create(code, electionId, officeId): tallySheetProof = Proof.create( proofType=ProofTypeEnum.ManuallyFilledTallySheets) result = Model(electionId=electionId, code=code, officeId=officeId, tallySheetProofId=tallySheetProof.proofId) db.session.add(result) db.session.commit() return result
def __init__(self, submissionType, electionId, areaId): submissionProof = Proof.create(proofType=get_submission_proof_type( submissionType=submissionType)) submissionHistory = History.create() super(SubmissionModel, self).__init__(submissionId=submissionHistory.historyId, electionId=electionId, submissionType=submissionType, areaId=areaId, submissionProofId=submissionProof.proofId) db.session.add(self) db.session.flush()
def __init__(self, invoiceId, stationaryItemId): if Invoice.has_confirmed(invoiceId): raise ForbiddenException("Stationary items cannot be added to confirmed invoices (%d)" % invoiceId) elif StationaryItem.is_locked(stationaryItemId): raise ForbiddenException("Stationary item is not available (%d)" % stationaryItemId) else: received_proof = Proof.create( proofType=ProofTypeEnum.InvoiceStationaryItemReceive ) super(InvoiceStationaryItemModel, self).__init__( invoiceId=invoiceId, stationaryItemId=stationaryItemId, receivedProofId=received_proof.proofId )
def create(submissionType, electionId, officeId, electorateId=None, parentSubmissionId=None): submissionProof = Proof.create(proofType=get_submission_proof_type( submissionType=submissionType)) submissionHistory = History.create() result = Model(electionId=electionId, submissionType=submissionType, officeId=officeId, electorateId=electorateId, parentSubmissionId=parentSubmissionId, submissionProofId=submissionProof.proofId, submissionHistoryId=submissionHistory.historyId) db.session.add(result) db.session.commit() return result
def create(invoiceId, stationaryItemId): if Invoice.has_confirmed(invoiceId): raise ForbiddenException("Stationary items cannot be added to confirmed invoices (%d)" % invoiceId) elif StationaryItem.is_locked(stationaryItemId): raise ForbiddenException("Stationary item is not available (%d)" % stationaryItemId) else: received_proof = Proof.create( proofType=ProofTypeEnum.InvoiceStationaryItemReceive ) print("######################### received_proof ###", received_proof) print("######################### received_proof.proofId ###", received_proof.proofId) result = Model( invoiceId=invoiceId, stationaryItemId=stationaryItemId, receivedProofId=received_proof.proofId ) db.session.add(result) db.session.commit() return result