Skip to content

Commit

Permalink
visibale roles
Browse files Browse the repository at this point in the history
  • Loading branch information
qinmingyuan committed Jan 15, 2025
1 parent 4efff2c commit 616a035
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
6 changes: 2 additions & 4 deletions app/models/roled/ext/job_title.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ module Ext::JobTitle
include Ext::Base
end

def default_role_hash
Rails.cache.fetch('job_title_role_hash') do
JobTitleRole.find_by(default: true)&.role_hash || {}
end
def visible_roles
Role.joins(:role_types).where(role_types: { who_type: 'Org::JobTitle' }).visible
end

end
Expand Down
4 changes: 4 additions & 0 deletions app/models/roled/ext/member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ module Ext::Member
include Ext::Base
end

def visible_roles
Role.joins(:role_types).where(role_types: { who_type: 'Org::Member' }).visible
end

end
end
4 changes: 4 additions & 0 deletions app/models/roled/ext/organ.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@ module Ext::Organ
include Ext::Base
end

def visible_roles
Role.joins(:role_types).where(role_types: { who_type: 'Org::Organ' }).visible
end

end
end
4 changes: 4 additions & 0 deletions app/models/roled/ext/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ module Ext::User
include Ext::Base
end

def visible_roles
Role.joins(:role_types).where(role_types: { who_type: 'Auth::User' }).visible
end

def admin?
if respond_to?(:account_identities) && (RailsCom.config.default_admin_accounts & account_identities).length > 0
true
Expand Down

0 comments on commit 616a035

Please sign in to comment.