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
This commit is contained in:
z-bowen 2018-09-05 14:10:24 +02:00
parent 5cde9c8b08
commit b1c9d7de86

View File

@ -224,6 +224,15 @@ class Election(Transaction):
def store_election(cls, bigchain, election, height): def store_election(cls, bigchain, election, height):
bigchain.store_election(height, election) 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 @classmethod
def is_approved(cls, bigchain, new_height, txns): def is_approved(cls, bigchain, new_height, txns):
votes = {} votes = {}
@ -247,6 +256,3 @@ class Election(Transaction):
@classmethod @classmethod
def on_approval(cls, bigchain, election, new_height): def on_approval(cls, bigchain, election, new_height):
raise NotImplementedError raise NotImplementedError
def show_election(self, bigchain):
raise NotImplementedError