예제 #1
0
def update(invoiceId, stationaryItemId, received=False, receivedFrom=None, receivedOfficeId=None, scannedImages=None):
    instance = get_by_id(invoiceId, stationaryItemId)

    # if scannedImages is not None:
    #     file = Image.create(fileSource=scannedImages)
    #     FolderFile.create(folderId=instance.receivedScannedFilesFolderId, fileId=file.fileId)

    # TODO support muliple images
    # https://github.com/zalando/connexion/issues/510

    if instance is None:
        raise NotFoundException("Invoice Stationary Item not found associated with the given invoiceId (%d, %d)"
                                % (invoiceId, stationaryItemId))
    else:
        if received is not None:
            instance.received = received
        if receivedFrom is not None:
            instance.receivedFrom = receivedFrom
        if receivedOfficeId is not None:
            instance.receivedOfficeId = receivedOfficeId

        if instance.received is True:
            Proof.update(
                proofId=instance.receivedProofId,
                finished=True
            )

        instance.receivedBy = Auth().get_user_id()
        instance.receivedAt = datetime.now()

        db.session.flush()

        return instance
예제 #2
0
    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
예제 #3
0
def finish(proofId):
    result = Proof.update(
        finished=True,
        proofId=proofId
    )

    return Schema().dump(result).data, 201
예제 #4
0
def get_by_id(proofId):
    result = Proof.get_by_id(proofId=proofId)

    if result is None:
        raise NotFoundException("Proof not found. (proofId=%d)" % proofId)

    return Schema().dump(result).data
예제 #5
0
def get_by_id(proofId):
    result = Proof.get_by_id(proofId=proofId)

    if result is None:
        raise NotFoundException("Proof not found. (proofId=%d)" % proofId,
                                code=MESSAGE_CODE_PROOF_NOT_FOUND)

    return Schema().dump(result).data
예제 #6
0
    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
예제 #7
0
def upload_file(body):
    request_body = RequestBody(body)
    result = Proof.upload_file(
        proofId=request_body.get("proofId"),
        fileSource=connexion.request.files['scannedFile'],
        fileType=FileTypeEnum.Image
    )

    return Schema().dump(result).data, 201
def finish(proofId):
    result = Proof.update(
        finished=True,
        proofId=proofId
    )

    db.session.commit()

    return Schema().dump(result).data, 201
예제 #9
0
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
예제 #10
0
    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()
예제 #11
0
    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
예제 #14
0
def get_all():
    result = Proof.get_all()

    result = get_paginated_query(result).all()

    return Schema(many=True).dump(result).data
예제 #15
0
def get_by_id(proofId):
    result = Proof.get_by_id(proofId=proofId)

    return Schema().dump(result).data
예제 #16
0
def get_all():
    result = Proof.get_all()

    return Schema(many=True).dump(result).data