コード例 #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 get_all(ballotId=None, ballotType=None, electionId=None):
    result = Ballot.get_all(
        ballotId=ballotId,
        ballotType=ballotType,
        electionId=electionId
    )

    return Schema(many=True).dump(result).data
コード例 #3
0
def get_all(ballotId=None):
    result = Ballot.get_all(ballotId=ballotId)

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