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

Update the AdminSet permissions when removing a PermissionTemplateAccess #584

Merged
merged 1 commit into from
Mar 17, 2017

Conversation

jcoyne
Copy link
Member

@jcoyne jcoyne commented Mar 17, 2017

Fixes #570

# Calculate and update who should have edit access based on who
# has "manage" access in the PermissionTemplateAccess
def update_access_controls!
update!(edit_users: permission_template.access_grants.where(access: 'manage', agent_type: 'user').pluck(:agent_id),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you extract local variables for these two lines. They are rather long and hard to quickly parse.

new_edit_users = permission_template.access_grants.where(access: 'manage', agent_type: 'user').pluck(:agent_id)
new_edit_groups = permission_template.access_grants.where(access: 'manage', agent_type: 'group').pluck(:agent_id)
update!(edit_users: new_edit_users, edit_groups: new_edit_groups)

jeremyf added a commit that referenced this pull request Mar 17, 2017
There was a lot of external knowledge regarding the structure of the
permission template. Instead, encapsulate that knowledge in a method
on the permission template.

Related to #584
jeremyf added a commit that referenced this pull request Mar 17, 2017
There was a lot of external knowledge regarding the structure of the
permission template. Instead, encapsulate that knowledge in a method
on the permission template.

Related to #584
@jeremyf jeremyf merged commit 5a96dbb into master Mar 17, 2017
@jeremyf jeremyf deleted the fix_570 branch March 17, 2017 20:42
jeremyf added a commit that referenced this pull request Mar 17, 2017
There was a lot of external knowledge regarding the structure of the
permission template. Instead, encapsulate that knowledge in a method
on the permission template.

Related to #584
jeremyf added a commit that referenced this pull request Mar 17, 2017
There was a lot of external knowledge regarding the structure of the
permission template. Instead, encapsulate that knowledge in a method
on the permission template.

Related to #584
jeremyf added a commit that referenced this pull request Mar 20, 2017
There was a lot of external knowledge regarding the structure of the
permission template. Instead, encapsulate that knowledge in a method
on the permission template.

Related to #584
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.

2 participants