コード例 #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 create(body):
    request_body = RequestBody(body)
    result = Ballot.create(electionId=request_body.get("electionId"),
                           ballotId=request_body.get("ballotId"),
                           ballotType=get_ballot_type(
                               request_body.get("ballotType")))

    db.session.commit()

    return Schema().dump(result).data, 201
コード例 #4
0
def get_all(ballotId=None):
    result = Ballot.get_all(ballotId=ballotId)

    return Schema(many=True).dump(result).data
コード例 #5
0
def create(body):
    request_body = RequestBody(body)
    result = Ballot.create(electionId=request_body.get("electionId"),
                           ballotId=request_body.get("ballotId"))

    return Schema().dump(result).data, 201