Commit 68c76c67 authored by Vitalii Fisenko's avatar Vitalii Fisenko
Browse files

Remove winners from public meta

parent 01cdaefc
......@@ -153,19 +153,6 @@ class DutchRound(base_states.TimeState):
def stop_round(self, bid_obj):
self._auction.bidsInfo[bid_obj.id].priority = int(self.state_spec['priority_to_set'])
self._auction.public_meta.update({'dutch_status': 'stopped'})
bid = bid_obj.to_primitive()
amount_str = utils.format_bid(bid['amount'])
self._auction.public_meta['winners'] = {
'dutch_round': {
'bidder': bid['id'],
'amount': bid['amount'],
'amount_str': {
'uk_UA': f'{amount_str} {self._auction.ua_currency}',
'en_US': f'{amount_str} {self._auction.currency}'
},
'time': bid['datePublished']
}
}
self._auction.bidsHistory.append([bid_obj])
def _get_sorted_bids(self):
......@@ -231,7 +218,7 @@ class DutchRound(base_states.TimeState):
winner_bid = bids[0] if bids else None
self.auction_protocol['timeline']['dutch_round'].update({
'stop_bid': winner_bid,
'stop_time': str(self._auction.public_meta['winners']['dutch_round']['time'])
'stop_time': str(self._auction.bids[winner_bid].datePublished) if winner_bid else None
})
......
......@@ -193,28 +193,8 @@ class SimultaneousRound(mixins.BaseLimitValueMixin, base_states.TimeState):
self._final_auction_protocol_set_up()
round_bids = [bid for bid in bids.values() if bid.amount and bid.id in self.round_bids_id]
self._auction.bidsHistory.append(round_bids)
self.set_winners(round_bids)
super().onExit()
def set_winners(self, round_bids):
if not round_bids:
return
winner_obj = round_bids[0]
winners = self._auction.public_meta.get('winners', {})
winner = winner_obj.to_primitive()
amount_str = utils.format_bid(winner['amount'])
winners[self.state_name] = {
'bidder': winner['id'],
'decimal_amount': winner_obj.amount,
'amount': winner['amount'],
'amount_str': {
'uk_UA': f'{amount_str} {self._auction.ua_currency}',
'en_US': f'{amount_str} {self._auction.currency}'
},
'time': winner['datePublished']
}
self._auction.public_meta['winners'] = winners
def _initial_auction_protocol_set_up(self):
self._auction.auction_protocol['timeline'][self._auction.current_state] = {
'start_date': str(datetime.now()),
......
......@@ -85,8 +85,6 @@ class DutchRoundTest(unittest.TestCase):
self.auction.place_bid(self.second_bid.id, 100, ctx2)
self.assertEqual(self.auction.public_meta['dutch_status'], 'stopped')
self.assertEqual(self.auction.public_meta['winners']['dutch_round']['bidder'], self.first_bid.id)
self.assertEqual(self.auction.public_meta['winners']['dutch_round']['amount'], 100)
self.assertEqual(self.auction.bidsInfo[self.first_bid.id].priority, 1)
def test_add_bid(self):
......@@ -230,10 +228,3 @@ class DutchAuctionTest(unittest.TestCase):
self.auction.place_bid(self.first_bid.id, 300, ctx1)
self.auction.set_state('done')
self.assertEqual(self.auction.public_meta['winners']['dutch_round']['bidder'], self.first_bid.id)
self.assertEqual(self.auction.public_meta['winners']['dutch_round']['amount'], 100)
self.assertEqual(self.auction.public_meta['winners']['simultaneous_round']['bidder'], self.third_bid.id)
self.assertEqual(self.auction.public_meta['winners']['simultaneous_round']['amount'], 210)
self.assertEqual(self.auction.public_meta['winners']['precedence_round']['bidder'], self.first_bid.id)
self.assertEqual(self.auction.public_meta['winners']['precedence_round']['amount'], 300)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment