summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
b6e8226)
Condense the Turbot Home view to only link to hunts, not give all the
details.
Change hunt_blocks() function to return an array of array of blocks,
(broken up at the level of a round). Callers now generate one post for
each element in the outer array. Hopefully this gives us a little
breathing room for now.
from turbot.blocks import (
section_block, text_block, button_block, actions_block, divider_block
)
from turbot.blocks import (
section_block, text_block, button_block, actions_block, divider_block
)
-from turbot.hunt import hunt_blocks, find_hunt_for_hunt_id
+from turbot.hunt import find_hunt_for_hunt_id
from turbot.sheets import (
sheets_create, sheets_create_for_puzzle, sheets_create_folder
)
from turbot.sheets import (
sheets_create, sheets_create_for_puzzle, sheets_create_folder
)
continue
if user_id in slack_channel_members(turb.slack_client,
hunt['channel_id']):
continue
if user_id in slack_channel_members(turb.slack_client,
hunt['channel_id']):
- my_hunt_blocks += hunt_blocks(turb, hunt, puzzle_status='all')
+ my_hunt_blocks.append(hunt_link_block(turb, hunt))
else:
available_hunt_blocks.append(hunt_link_block(turb, hunt))
else:
available_hunt_blocks.append(hunt_link_block(turb, hunt))
+ my_hunt_blocks.append([
section_block(text_block("You do not belong to any hunts"))
section_block(text_block("You do not belong to any hunts"))
if len(available_hunt_blocks):
available_hunt_blocks = [
if len(available_hunt_blocks):
available_hunt_blocks = [
limit_to_rounds=None):
"""Generate Slack blocks for a hunt
limit_to_rounds=None):
"""Generate Slack blocks for a hunt
+ Returns a list of lists of blocks, (broken up by round so that
+ the receiver should do one Slack post for each entry in the
+ outer array.
+
The hunt argument should be a dictionary as returned from the
database.
The hunt argument should be a dictionary as returned from the
database.
button_block("✏", "edit_hunt", hunt_id)
)
]
button_block("✏", "edit_hunt", hunt_id)
)
]
if not len(puzzles):
text = "No puzzles found."
if puzzle_status != 'all':
text += ' (Consider searching for "all" puzzles?)'
if not len(puzzles):
text = "No puzzles found."
if puzzle_status != 'all':
text += ' (Consider searching for "all" puzzles?)'
section_block(text_block(text))
]
section_block(text_block(text))
]
continue
# If we're only displaying one round the round header is redundant
if limit_to_rounds and len(limit_to_rounds) == 1:
continue
# If we're only displaying one round the round header is redundant
if limit_to_rounds and len(limit_to_rounds) == 1:
- blocks += round_blocks(round, puzzles, omit_header=True)
+ block += round_blocks(round, puzzles, omit_header=True)
- blocks += round_blocks(round, puzzles)
- blocks.append(divider_block())
+ block += round_blocks(round, puzzles)
+ block.append(divider_block())
+ blocks.append([])
+ block = blocks[-1]
# Also blocks for any puzzles not in any round
stray_puzzles = [puzzle for puzzle in puzzles if 'rounds' not in puzzle]
# Also blocks for any puzzles not in any round
stray_puzzles = [puzzle for puzzle in puzzles if 'rounds' not in puzzle]
# to rounds but specifically the round of unassigned puzzles
if len(stray_puzzles) and not limit_to_rounds:
stray_text = "*Puzzles with no assigned round*"
# to rounds but specifically the round of unassigned puzzles
if len(stray_puzzles) and not limit_to_rounds:
stray_text = "*Puzzles with no assigned round*"
- blocks.append(section_block(text_block(stray_text)))
+ block.append(section_block(text_block(stray_text)))
for puzzle in stray_puzzles:
for puzzle in stray_puzzles:
- blocks += puzzle_blocks(puzzle)
+ block += puzzle_blocks(puzzle)
- blocks.append(divider_block())
+ block.append(divider_block())
blocks = hunt_blocks(turb, hunt, puzzle_status=status, search_terms=terms)
blocks = hunt_blocks(turb, hunt, puzzle_status=status, search_terms=terms)
- requests.post(response_url,
- json = { 'blocks': blocks },
- headers = {'Content-type': 'application/json'}
- )
+ for block in blocks:
+ requests.post(response_url,
+ json = { 'blocks': block },
+ headers = {'Content-type': 'application/json'}
+ )
limit_to_rounds=puzzle.get('rounds', [])
)
limit_to_rounds=puzzle.get('rounds', [])
)
- requests.post(response_url,
- json = { 'blocks': blocks },
- headers = {'Content-type': 'application/json'}
- )
+ for block in blocks:
+ requests.post(response_url,
+ json = { 'blocks': block },
+ headers = {'Content-type': 'application/json'}
+ )