From b1d6d356cb515e5b342227dbb998c4aaa745e364 Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Fri, 13 Jan 2017 18:07:00 +0100 Subject: [PATCH] Refactor votes API view to use required parser argument rather than custom logic --- bigchaindb/web/views/votes.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/bigchaindb/web/views/votes.py b/bigchaindb/web/views/votes.py index 9fb306a1..3f6000f6 100644 --- a/bigchaindb/web/views/votes.py +++ b/bigchaindb/web/views/votes.py @@ -19,18 +19,12 @@ class VotesApi(Resource): A list of votes voting for a block with ID ``block_id``. """ parser = reqparse.RequestParser() - parser.add_argument('block_id', type=str) + parser.add_argument('block_id', type=str, required=True) args = parser.parse_args(strict=True) - if sum(arg is not None for arg in args.values()) != 1: - return make_error(400, "Provide the block_id query parameter.") - pool = current_app.config['bigchain_pool'] - votes = [] - with pool() as bigchain: - if args['block_id']: - votes = list(backend.query.get_votes_by_block_id(bigchain.connection, args['block_id'])) + votes = list(backend.query.get_votes_by_block_id(bigchain.connection, args['block_id'])) return votes