summaryrefslogtreecommitdiff
path: root/http/api
diff options
context:
space:
mode:
Diffstat (limited to 'http/api')
-rw-r--r--http/api/api.py16
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)