]> git.cworth.org Git - turbot/blobdiff - turbot/interaction.py
Add a "meta" checkbox when creating/editing a puzzle
[turbot] / turbot / interaction.py
index f9640ca3473b3abb8adc8e742b9065112c389158..b22016107df99ae5127e4101d6cbe87abc0c4a3e 100644 (file)
@@ -160,6 +160,8 @@ def edit_puzzle(turb, puzzle, trigger_id):
             input_block("Puzzle URL", "url", "External URL of puzzle",
                         initial_value=puzzle.get("url", None),
                         optional=True),
+            checkbox_block("Is this a meta puzzle?", "Meta", "meta",
+                           checked=(puzzle.get('type', 'plain') == 'meta')),
             * round_options_block,
             input_block("New round(s)", "new_rounds",
                         "New round(s) this puzzle belongs to " +
@@ -212,6 +214,10 @@ def edit_puzzle_submission(turb, payload, metadata):
     url = state['url']['url']['value']
     if url:
         puzzle['url'] = url
+    if state['meta']['meta']['selected_options']:
+        puzzle['type'] = 'meta'
+    else:
+        puzzle['type'] = 'plain'
     rounds = [option['value'] for option in
               state['rounds']['rounds']['selected_options']]
     if rounds:
@@ -686,6 +692,7 @@ def new_puzzle(turb, body):
             input_block("Puzzle name", "name", "Name of the puzzle"),
             input_block("Puzzle URL", "url", "External URL of puzzle",
                         optional=True),
+            checkbox_block("Is this a meta puzzle?", "Meta", "meta"),
             * round_options_block,
             input_block("New round(s)", "new_rounds",
                         "New round(s) this puzzle belongs to " +
@@ -716,6 +723,10 @@ def new_puzzle_submission(turb, payload, metadata):
     state = payload['view']['state']['values']
     name = state['name']['name']['value']
     url = state['url']['url']['value']
+    if state['meta']['meta']['selected_options']:
+        puzzle_type = 'meta'
+    else:
+        puzzle_type = 'plain'
     if 'rounds' in state:
         rounds = [option['value'] for option in
                   state['rounds']['rounds']['selected_options']]
@@ -774,6 +785,7 @@ def new_puzzle_submission(turb, payload, metadata):
         "solution": [],
         "status": 'unsolved',
         "name": name,
+        "type": puzzle_type
     }
     if url:
         item['url'] = url