From b1c9d7de86afda5b838cf814cd102606fdd170b2 Mon Sep 17 00:00:00 2001 From: z-bowen Date: Wed, 5 Sep 2018 14:10:24 +0200 Subject: [PATCH] Problem: Default for `show_election` not implemented for `Election` class Solution: Create a default method that work if all fields in the 'asset[data]' can be displayed without additional formatting --- bigchaindb/common/election.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bigchaindb/common/election.py b/bigchaindb/common/election.py index ef748b24..56cdd3bf 100644 --- a/bigchaindb/common/election.py +++ b/bigchaindb/common/election.py @@ -224,6 +224,15 @@ class Election(Transaction): def store_election(cls, bigchain, election, height): bigchain.store_election(height, election) + def show_election(self, bigchain): + data = self.asset['data'] + response = '' + for k, v in data.items(): + response += f'{k}={v}\n' + response += self.get_status(bigchain) + + return response + @classmethod def is_approved(cls, bigchain, new_height, txns): votes = {} @@ -247,6 +256,3 @@ class Election(Transaction): @classmethod def on_approval(cls, bigchain, election, new_height): raise NotImplementedError - - def show_election(self, bigchain): - raise NotImplementedError