Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
Merge 0abfdbe into b3ab7ae
Browse files Browse the repository at this point in the history
  • Loading branch information
TimJentzsch authored Feb 28, 2022
2 parents b3ab7ae + 0abfdbe commit f56e525
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions api/slack/transcription_check/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,26 @@ def process_check_action(data: Dict) -> None:
reply_to_action_with_ping(
data, f"Check {check_id} is already claimed by someone!"
)
# Update to make sure the proper controls are shown
update_check_message(check)
return
# If it's not a claim it must already be claimed by someone
if action != "claim" and check.moderator is None:
logger.warning(f"Check {check_id} is not claimed by anyone yet!")
reply_to_action_with_ping(
data, f"Check {check_id} is not claimed by anyone yet!"
)
# Update to make sure the proper controls are shown
update_check_message(check)
return
# If the action isn't a claim, the check must already be claimed
if action != "claim" and check.moderator is None:
logger.warning(f"Check {check_id} has not been claimed yet!",)
reply_to_action_with_ping(
data, f"Check {check_id} has not been claimed yet!",
)
# Update to make sure the proper controls are shown
update_check_message(check)
return
# A claimed check can only be worked on by the mod who claimed it
if action != "claim" and check.moderator != mod:
Expand All @@ -113,6 +119,8 @@ def process_check_action(data: Dict) -> None:
data,
f"Check {check_id} is claimed by u/{check.moderator.username}, not by you!",
)
# Update to make sure the proper controls are shown
update_check_message(check)
return

# Try to update the DB model based on the action
Expand Down
4 changes: 2 additions & 2 deletions api/slack/transcription_check/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,18 @@ def construct_transcription_check_blocks(check: TranscriptionCheck) -> List[Dict
base_text = _get_check_base_text(check)
actions = _get_check_actions(check)
status_text = _get_check_status_text(check)
text = f"{base_text}\n{status_text}"

return [
{
"type": "section",
"text": {"type": "mrkdwn", "text": base_text},
"text": {"type": "mrkdwn", "text": text},
"accessory": {
"type": "image",
"image_url": submission.content_url,
"alt_text": f"Image of submission {submission.id}",
},
},
{"type": "divider"},
{"type": "section", "text": {"type": "mrkdwn", "text": status_text}},
{"type": "actions", "elements": actions},
]
4 changes: 2 additions & 2 deletions api/tests/slack/transcription_check/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def test_process_check_action_no_mod(client: Client) -> None:

assert check.status == CheckStatus.PENDING
assert check.moderator is None
assert update_mock.call_count == 0
assert update_mock.call_count == 1
assert reply_mock.call_count == 1


Expand Down Expand Up @@ -375,5 +375,5 @@ def test_process_check_action_wrong_mod(client: Client) -> None:

assert check.status == CheckStatus.PENDING
assert check.moderator == mod
assert update_mock.call_count == 0
assert update_mock.call_count == 1
assert reply_mock.call_count == 1

0 comments on commit f56e525

Please sign in to comment.