Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix transcription link not being picked up correctly #362

Merged
merged 2 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/slack/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def send_transcription_check(
) -> None:
"""Notify slack for the transcription check."""
gamma = user.gamma
msg = f"*Transcription check* for u/{user.username} ({user.gamma:,d}):\n"
msg = f"*Transcription check* for u/{user.username} ({user.gamma:,d} Γ):\n"

# Add relevant links
tor_url = (
Expand Down
10 changes: 9 additions & 1 deletion api/tests/submissions/test_submission_done.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,13 @@ def test_removed_transcription_check(
"api.views.submission.send_transcription_check"
) as mock:
client, headers, user = setup_user_client(client)
ocr_bot = create_user(id=123123, username="ocr_bot", is_bot=True)

submission = create_submission(tor_url="asdf", claimed_by=user)
create_transcription(submission, user, url=None, removed_from_reddit=True)
create_transcription(submission, ocr_bot, id=30, url=None)
transcription = create_transcription(
submission, user, id=40, url=None, removed_from_reddit=True
)

result = client.patch(
reverse("submission-done", args=[submission.id]),
Expand All @@ -186,8 +191,11 @@ def test_removed_transcription_check(
)

assert result.status_code == status.HTTP_201_CREATED

if has_low_activity:
assert mock.call_count == 1
# Make sure that the OCR transcription doesn't get picked up
assert mock.call_args[0][0].id == transcription.id
else:
assert mock.call_count == 0

Expand Down
6 changes: 3 additions & 3 deletions api/tests/test_slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ def test_dadjoke_target(message: str) -> None:
1,
"url_stuff",
"Low Activity",
"*Transcription check* for u/TESTosterone (1):\n"
"*Transcription check* for u/TESTosterone (1 Γ):\n"
"<foo|ToR Post> | <bar|Partner Post> | <url_stuff|Transcription>\n"
"Reason: Low Activity\n"
":rotating_light: First transcription! :rotating_light:",
Expand All @@ -584,15 +584,15 @@ def test_dadjoke_target(message: str) -> None:
10,
"url_stuff",
"Watched (70.0%)",
"*Transcription check* for u/TESTosterone (10):\n"
"*Transcription check* for u/TESTosterone (10 Γ):\n"
"<foo|ToR Post> | <bar|Partner Post> | <url_stuff|Transcription>\n"
"Reason: Watched (70.0%)",
),
(
20300,
None,
"Automatic (0.5%)",
"*Transcription check* for u/TESTosterone (20,300):\n"
"*Transcription check* for u/TESTosterone (20,300 Γ):\n"
"<foo|ToR Post> | <bar|Partner Post> | [Removed]\n"
"Reason: Automatic (0.5%)",
),
Expand Down
4 changes: 3 additions & 1 deletion api/views/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,9 @@ def done(self, request: Request, pk: int, username: str = None) -> Response:
if submission.claimed_by != user:
return Response(status=status.HTTP_412_PRECONDITION_FAILED)

transcription = Transcription.objects.filter(submission=submission).first()
transcription = Transcription.objects.filter(
submission=submission, author=user
).first()

if transcription is None:
return Response(status=status.HTTP_428_PRECONDITION_REQUIRED)
Expand Down