-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add rake task to import current Roles to new permission system #361
Add rake task to import current Roles to new permission system #361
Conversation
bc04003
to
50c2659
Compare
50c2659
to
2e874bd
Compare
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.
Thanks @the-krg, nice work! I left some comments.
namespace :solidus do | ||
desc "Import existing permission sets to role permissions table" | ||
task import_existing_permission_sets: :environment do | ||
Spree::PermissionSets::Base.subclasses.each do |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.
Should we prepend with Zeitwerk::Loader.eager_load_all
? Otherwise, we might skip subclasses that haven't yet been loaded in the development environment.
Also, should we consider subclasses of subclasses?
For both questions, I'm thinking about user-defined permission sets, as they're not a problem in vanilla Solidus.
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.
Great suggestion!
Did some tests with custom permission sets on Sandbox and it worked.
Also changed from subclasses
to descendants
, so we do get subclasses of subclasses as well as permission sets inherited from other permission sets.
2e874bd
to
1744dc8
Compare
This commit introduces a simple rake task that imports the Permission Sets to the DB, then iterates over the defined permissions on AppConfiguration to create the RolePermissions.
1744dc8
to
5adee72
Compare
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.
❤️
ef2de84
into
rainerd/incorporate-roles-management-code-into-the-core
Summary
This rake task creates
Spree::PermissionSet
records for each existing permission set subclass inSpree::PermissionSets::*
, andSpree::RolePermission
records for each role's associated permission sets.(It is designed to work with both new installations and existing Solidus stores that have custom roles and permissions).
Usage