コード例 #1
0
    def __init__(self, electionId, fromBallotId, toBallotId):
        fromBallot = Ballot.get_all(ballotId=fromBallotId,
                                    electionId=electionId)
        toBallot = Ballot.get_all(ballotId=toBallotId, electionId=electionId)

        if len(fromBallot) is 0:
            raise NotFoundException("Ballot not found (ballotId=%s)" %
                                    fromBallotId)
        else:
            fromBallot = fromBallot[0]

        if len(toBallot) is 0:
            raise NotFoundException("Ballot not found (ballotId=%s)" %
                                    toBallotId)
        else:
            toBallot = toBallot[0]

        stationary_item = StationaryItem.create(
            electionId=electionId,
            stationaryItemType=StationaryItemTypeEnum.Ballot)

        super(BallotBookModel, self).__init__(
            fromBallotStationaryItemId=fromBallot.stationaryItemId,
            toBallotStationaryItemId=toBallot.stationaryItemId,
            stationaryItemId=stationary_item.stationaryItemId)

        db.session.add(self)
        db.session.flush()
コード例 #2
0
    def __init__(self, ballotId, electionId):
        stationary_item = StationaryItem.create(
            electionId=electionId,
            stationaryItemType=StationaryItemTypeEnum.Ballot)

        self.ballotId = ballotId
        self.electionId = electionId
        self.stationaryItemId = stationary_item.stationaryItemId
コード例 #3
0
    def __init__(self, ballotBoxId, electionId):
        stationary_item = StationaryItem.create(
            electionId=electionId,
            stationaryItemType=StationaryItemTypeEnum.BallotBox)

        super(BallotBoxModel,
              self).__init__(ballotBoxId=ballotBoxId,
                             electionId=electionId,
                             stationaryItemId=stationary_item.stationaryItemId)

        db.session.add(self)
        db.session.flush()
コード例 #4
0
    def __init__(self,
                 ballotId,
                 electionId,
                 ballotType=BallotTypeEnum.Ordinary):
        stationary_item = StationaryItem.create(
            electionId=electionId,
            stationaryItemType=StationaryItemTypeEnum.Ballot)

        super(BallotModel,
              self).__init__(ballotId=ballotId,
                             electionId=electionId,
                             stationaryItemId=stationary_item.stationaryItemId,
                             ballotType=ballotType)
コード例 #5
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
            )
コード例 #6
0
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
コード例 #7
0
def get_all():
    result = StationaryItem.get_all()

    result = get_paginated_query(result).all()

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