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

Bugfix: FWF-3748: Fix keyerror for a user with create_designs and create_submissions on accessing formlist with includeSubmissionsCount=true #2538

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
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def get(): # pylint: disable=too-many-locals
is_designer=is_designer,
active_forms=active_forms,
include_submissions_count=include_submissions_count,
ignore_designer=ignore_designer,
)
return (
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def get_all_forms( # pylint: disable=too-many-positional-arguments
is_designer: bool,
active_forms: bool,
include_submissions_count: bool,
ignore_designer: bool,
**kwargs,
): # pylint: disable=too-many-arguments, too-many-locals
"""Get all forms."""
Expand Down Expand Up @@ -93,7 +94,13 @@ def get_all_forms( # pylint: disable=too-many-positional-arguments
)
mapper_schema = FormProcessMapperSchema()
mappers_response = mapper_schema.dump(mappers, many=True)
if include_submissions_count and CREATE_SUBMISSIONS in user.roles:
# Submissions count should return only for user with create_submissions permission
# & client form listing with showForOnlyCreateSubmissionUsers param true
if (
include_submissions_count
and CREATE_SUBMISSIONS in user.roles
and ignore_designer
):
current_app.logger.debug("Fetching submissions count..")
for mapper in mappers_response:
mapper["submissionsCount"] = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ def test_form_list_submission_count(app, client, session, jwt, create_mapper):
token = get_token(jwt, role=CREATE_SUBMISSIONS)
headers = {"Authorization": f"Bearer {token}", "content-type": "application/json"}
# submissionsCount exclude draft and return submission count
response = client.get("/form?includeSubmissionsCount=true", headers=headers)
response = client.get("/form?includeSubmissionsCount=true&showForOnlyCreateSubmissionUsers=true", headers=headers)
assert response.status_code == 200
forms = response.json["forms"]
assert len(forms) == 1
Expand Down
Loading