-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance Role model for better role management
This commit expands the functionality of the `Spree::Role` model to provide more granular and efficient control over user roles and permissions. * Spree::RolePermission * Spree::Role enhancements * Spree::PermissionSet These enhancements are a part of our broader initiative to improve the flexibility and extensibility of role and permission management in Solidus, adapting functionality from the `solidus_user_roles` gem.
- Loading branch information
1 parent
82b8580
commit 3bbbf0c
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Spree | ||
class PermissionSet < Spree::Base | ||
has_many :role_permissions | ||
has_many :roles, through: :role_permissions | ||
|
||
validates :name, :set, presence: true | ||
|
||
scope :display_permissions, -> { where('name LIKE ?', '%Display') } | ||
scope :management_permissions, -> { where('name LIKE ?', '%Management') } | ||
|
||
scope :custom_permissions, -> { | ||
where.not(id: display_permissions) | ||
.where.not(id: management_permissions) | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
module Spree | ||
class RolePermission < Spree::Base | ||
belongs_to :role | ||
belongs_to :permission_set | ||
end | ||
end |