-
Notifications
You must be signed in to change notification settings - Fork 7
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
IA-3024: Not displaying permissions related to modules which are not linked to the account #1328
IA-3024: Not displaying permissions related to modules which are not linked to the account #1328
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I have a few comments on the form that you can fix if you agree with them.
iaso/api/permissions.py
Outdated
permissions = perms.filter(codename__in=PERMISSIONS_PRESENTATION[group]) | ||
if permissions: | ||
result[group] = [] | ||
for permission in permissions: | ||
result[group].append( | ||
{"id": permission.id, "name": _(permission.name), "codename": permission.codename} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
permissions = perms.filter(codename__in=PERMISSIONS_PRESENTATION[group]) | |
if permissions: | |
result[group] = [] | |
for permission in permissions: | |
result[group].append( | |
{"id": permission.id, "name": _(permission.name), "codename": permission.codename} | |
) | |
for permission in perms.filter(codename__in=PERMISSIONS_PRESENTATION[group]): | |
result[group] = [] | |
result[group].append({"id": permission.id, "name": _(permission.name), "codename": permission.codename}) |
I think you can keep the previous code and just move the result[group] = []
line inside the for
loop.
This could save a bunch of statements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But at each loop it will remove the previous added permission and at the end result[group] will have the last permission
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you're right!
But that's strange because I ran the unit tests with this modified code and they were successful 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.assertTrue( set([permission["codename"] for permission in response.json()["permissions"]["org_units"]]) <= set(PERMISSIONS_PRESENTATION["org_units"]), )
. Maybe I did it wrong here?
Co-authored-by: Marc Hertzog <[email protected]>
Co-authored-by: Marc Hertzog <[email protected]>
Explain what problem this PR is resolving
Related JIRA tickets : IA-3024
Self proofreading checklist
Changes
How to test
Print screen / video
Screencast.from.2024-05-24.16-02-47.webm