diff options
author | emkael <emkael@tlen.pl> | 2019-05-31 20:51:05 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-05-31 20:51:05 +0200 |
commit | a9944c178f13ed6fd876a8757a147ca5949d6423 (patch) | |
tree | d07531b8449e96bd6c0b7f5b929d5baf0d5bba5c /http/api/api.py | |
parent | e7f7ae45b7dfd45a8b2ac0603a501273a5f10b2d (diff) |
Board preview feature
Diffstat (limited to 'http/api/api.py')
-rw-r--r-- | http/api/api.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/http/api/api.py b/http/api/api.py index 1c1cb0f..be2635f 100644 --- a/http/api/api.py +++ b/http/api/api.py @@ -63,6 +63,22 @@ def handle_upload(response, request): input_file.close() if not len(dealset): raise RuntimeError('Dealset is empty') + if params['display_deals']: + preview_obj = [] + for board in dealset: + deal_preview = { + 'number': board.number, + 'conditions': 'nesw'[board.dealer], + 'hands': [] + } + for pair in ['ns', 'ew']: + if board.vulnerable[pair.upper()]: + deal_preview['conditions'] += '-' + pair + deal_preview['hands'] = board.hands + preview_obj.append(deal_preview) + return_obj['preview'] = preview_obj + else: + return_obj['preview'] = None except RuntimeError as e: return_obj['error'] = unicode(e) return _print_response(response, return_obj) |