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

Post PR updates #79

Merged
merged 8 commits into from
Nov 20, 2024
Merged

Post PR updates #79

merged 8 commits into from
Nov 20, 2024

Conversation

Charl1996
Copy link
Contributor

This PR addresses the promised changes here and does a small refactor to simplify the code.

"can_write": can_write,
"can_read": can_read,
}, roles
return can_read, can_write, roles
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method seems redundant, but it's providing a more clear structure to the expected results in the test.

For instance, instead of doing this in the test

  get_domain_access_mock.return_value = (False, False ,["sql_lab", "dataset_editor"])

I can do this

get_domain_access_mock.return_value = self._to_permissions_response(
    can_write=False,
    can_read=False,
    roles=["sql_lab", "dataset_editor"],
)

Using a method like this makes it more clear what each value means.

are defined on CommCare HQ.

Any additional roles defined on CommCare HQ will also be assigned to the user.
3. Either the Gamma role for "edit" users or the READ_ONLY_ROLE_NAME for "view only" user
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: what is an "edit" user? or "view only" user? in terms of CCA

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user_role = GAMMA_ROLE_NAME
else:
self._ensure_read_only_role_exists()
user_role = READ_ONLY_ROLE_NAME

roles_names.append(user_role)
platform_roles_names.append(user_role)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to avoid editing an mutable object. This can cause confusion since the original object is being edited here.
Rather make a new list using platform_roles_names and then append to it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

➕ 1️⃣

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@mkangia mkangia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very well.

Just one blocking feedback which is easy to fix, if needed.

def _user_has_no_access(permissions: dict):
user_has_access = any([permissions[p] for p in permissions])
return not user_has_access
return hq_permissions["can_view"], hq_permissions["can_edit"], roles
Copy link
Contributor

@kaapstorm kaapstorm Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous return on line 223 returns a dict and a list, but this returns two bools and a list. It looks like you need to update line 223.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test that returns a status code other than 200 would be cool, because it would have flagged the problem.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, great catch @kaapstorm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaapstorm

Will update!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thank you.

@Charl1996 Charl1996 merged commit 1f2e669 into master Nov 20, 2024
3 checks passed
@Charl1996 Charl1996 deleted the due-updates branch November 20, 2024 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants