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

Only show the complete-review reminder where there are files to review #431

Merged
merged 1 commit into from
Jun 28, 2024
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
17 changes: 11 additions & 6 deletions airlock/views/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,17 @@ def request_view(request, request_id: str, path: str = ""):
request=release_request.id, group=group, exclude_readonly=True, size=20
)

user_has_completed_review = (
request.user.username in release_request.completed_reviews
)
user_has_reviewed_all_files = release_request.all_files_reviewed_by_reviewer(
request.user
)
if not is_author:
user_has_completed_review = (
request.user.username in release_request.completed_reviews
)
user_has_reviewed_all_files = (
release_request.output_files()
and release_request.all_files_reviewed_by_reviewer(request.user)
)
else:
user_has_completed_review = False
user_has_reviewed_all_files = False

if user_has_reviewed_all_files and not user_has_completed_review:
messages.success(
Expand Down
47 changes: 47 additions & 0 deletions tests/integration/views/test_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,53 @@ def test_request_view_with_submitted_request(airlock_client):
assert "Complete review" in response.rendered_content


@pytest.mark.parametrize(
"files,has_message",
[
([], False),
([factories.request_file()], False),
([factories.request_file(filetype=RequestFileType.SUPPORTING)], False),
(
[
factories.request_file(approved=True),
factories.request_file(path="unapproved.txt"),
],
False,
),
([factories.request_file(rejected=True)], True),
(
[
factories.request_file(approved=True),
factories.request_file(
path="supporting.txt", filetype=RequestFileType.SUPPORTING
),
],
True,
),
],
)
def test_request_view_complete_review_message(airlock_client, files, has_message):
checker = factories.get_default_output_checkers()[0]
airlock_client.login(checker.username, output_checker=True)
release_request = factories.create_request_at_status(
"workspace", status=RequestStatus.SUBMITTED, files=files
)

response = airlock_client.get(f"/requests/view/{release_request.id}", follow=True)

# The all-files-reviewed reminder message is only shown if the request has
# output files and all have been reviewed
if has_message:
assert "All files reviewed" in list(response.context["messages"])[0].message
else:
assert not list(response.context["messages"])

# The all-files-reviewed reminder message is never shown to an author
airlock_client.login(release_request.author, workspaces=["workspace"])
response = airlock_client.get(f"/requests/view/{release_request.id}", follow=True)
assert not list(response.context["messages"])


def test_request_view_with_reviewed_request(airlock_client):
# Login as 1st default output-checker
airlock_client.login("output-checker-0", output_checker=True)
Expand Down