forked from External/greenlight
GRN2-xx: Switch the relation between users and roles to make queries cleaner and faster (#1299)
* First steps * Fixes in account creation flow * Fixed most testcases * more test fixes * Fixed more test cases * Passing tests and rubocop * Added rake task to remove rooms
This commit is contained in:
@ -26,7 +26,7 @@ module UsersHelper
|
||||
end
|
||||
|
||||
def disabled_roles(user)
|
||||
current_user_role = current_user.highest_priority_role
|
||||
current_user_role = current_user.role
|
||||
|
||||
# Admins are able to remove the admin role from other admins
|
||||
# For all other roles they can only add/remove roles with a higher priority
|
||||
@ -38,7 +38,7 @@ module UsersHelper
|
||||
.pluck(:id)
|
||||
end
|
||||
|
||||
user.roles.by_priority.pluck(:id) | disallowed_roles
|
||||
[user.role.id] + disallowed_roles
|
||||
end
|
||||
|
||||
# Returns language selection options for user edit
|
||||
@ -52,6 +52,11 @@ module UsersHelper
|
||||
language_opts.sort
|
||||
end
|
||||
|
||||
# Returns a list of roles that the user can have
|
||||
def role_options
|
||||
Role.editable_roles(@user_domain).where("priority >= ?", current_user.role.priority)
|
||||
end
|
||||
|
||||
# Parses markdown for rendering.
|
||||
def markdown(text)
|
||||
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
|
||||
|
Reference in New Issue
Block a user