diff --git a/Gemfile b/Gemfile
index b9b5c5f..c58aed1 100644
--- a/Gemfile
+++ b/Gemfile
@@ -45,6 +45,7 @@
gem "better_errors"
gem "binding_of_caller"
gem 'web-console', '~>2.0'
+ gem 'rack-mini-profiler'
end
#
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index f35e0bd..761ea19 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -74,6 +74,7 @@
def admin_index
authorize User
+ @users = current_user.organisation.users.includes(:roles, :project_groups)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @organisation_users }
@@ -82,6 +83,7 @@
def admin_api_update
authorize User
+ @users = current_user.organisation.users.includes(:roles, :project_groups)
#iterate through all org users
user_ids = params[:api_user_ids].blank? ? [] : params[:api_user_ids].map(&:to_i)
admin_user_ids = params[:org_admin_ids].blank? ? [] : params[:org_admin_ids].map(&:to_i)
diff --git a/app/models/user.rb b/app/models/user.rb
index cbb5cd7..5ce0481 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -178,8 +178,7 @@
#
# @return [Boolean] true if the user can add new organisations
def can_add_orgs?
- add_orgs = roles.find_by(name: constant("user_role_types.add_organisations"))
- return !add_orgs.nil?
+ roles.include? Role.find_by(name: constant("user_role_types.add_organisations"))
end
##
@@ -187,8 +186,7 @@
#
# @return [Boolean] true if the user can change their organisation affiliations
def can_change_org?
- change_org = roles.find_by(name: constant("user_role_types.change_org_affiliation"))
- return !change_org.nil?
+ roles.include? Role.find_by(name: constant("user_role_types.change_org_affiliation"))
end
##
@@ -196,8 +194,7 @@
#
# @return [Boolean] true if the user can grant their permissions to others
def can_grant_permissions?
- grant_perms = roles.find_by(name: constant("user_role_types.grant_permissions"))
- return !grant_perms.nil?
+ roles.include? Role.find_by(name: constant("user_role_types.grant_permissions"))
end
##
@@ -205,8 +202,7 @@
#
# @return [Boolean] true if the user can modify organisation templates
def can_modify_templates?
- modify_temp = roles.find_by(name: constant("user_role_types.modify_templates"))
- return !modify_temp.nil?
+ roles.include? Role.find_by(name: constant("user_role_types.modify_templates"))
end
##
@@ -214,8 +210,7 @@
#
# @return [Boolean] true if the user can modify organistion guidance
def can_modify_guidance?
- modify_guidance = roles.find_by(name: constant("user_role_types.modify_guidance"))
- return !modify_guidance.nil?
+ roles.include? Role.find_by(name: constant("user_role_types.modify_guidance"))
end
##
@@ -223,8 +218,7 @@
#
# @return [Boolean] true if the user can use the api
def can_use_api?
- use_api = roles.find_by(name: constant("user_role_types.use_api"))
- return !use_api.nil?
+ roles.include? Role.find_by(name: constant("user_role_types.use_api"))
end
##
@@ -232,8 +226,7 @@
#
# @return [Boolean] true if the user can modify the org's details
def can_modify_org_details?
- modify_org_details = roles.find_by(name: constant("user_role_types.change_org_details"))
- return !modify_org_details.nil?
+ roles.include? Role.find_by(name: constant("user_role_types.change_org_details"))
end
##
@@ -241,8 +234,7 @@
#
# @return [Boolean] true if the user can grant api permissions to organisations
def can_grant_api_to_orgs?
- grant_api = roles.find_by(name: constant('user_role_types.grant_api_to_orgs'))
- return !grant_api.nil?
+ roles.include? Role.find_by(name: constant('user_role_types.grant_api_to_orgs'))
end
##
diff --git a/app/views/users/admin_api_update.html.erb b/app/views/users/admin_api_update.html.erb
index 2585634..2881667 100644
--- a/app/views/users/admin_api_update.html.erb
+++ b/app/views/users/admin_api_update.html.erb
@@ -5,56 +5,55 @@
<%= raw t('org_admin.user_text_html')%>
-<% @users = current_user.organisation.users %>
-
-
-
- | <%= t('org_admin.user_full_name') %> |
- <%= t('org_admin.user_name') %> |
- <%= t('org_admin.last_logged_in') %> |
- <%= t('org_admin.how_many_plans') %> |
- <%= t('org_admin.is_org_admin') %> |
- <% if current_user.organisation.token_permission_types.count > 0 %>
- <%= t('org_admin.api_privleges') %> |
- <% end %>
-
-
+
+
+
+ | <%= t('org_admin.user_full_name') %> |
+ <%= t('org_admin.user_name') %> |
+ <%= t('org_admin.last_logged_in') %> |
+ <%= t('org_admin.how_many_plans') %> |
+ <%= t('org_admin.is_org_admin') %> |
+ <% if current_user.organisation.token_permission_types.count > 0 %>
+ <%= t('org_admin.api_privleges') %> |
+ <% end %>
+
+
-
- <%= form_tag( admin_api_update_users_path, method: :put) do %>
- <% @users.each do |user| %>
- <% if !user.nil? then%>
-
- |
- <% if !user.name.nil? then%>
- <%= user.name %>
- <% end %>
- |
-
- <%= user.email %>
- |
-
- <% if !user.last_sign_in_at.nil? then%>
- <%= l user.last_sign_in_at.to_date, :formats => :short %>
- <% end %>
- |
-
- <% if !user.project_groups.nil? then%>
- <%= user.project_groups.count %>
- <% end %>
- |
-
- <%= check_box_tag "org_admin_ids[]", user.id, user.can_org_admin? %>
- |
- <% if current_user.organisation.token_permission_types.count > 0 %>
-
- <%= check_box_tag "api_user_ids[]", user.id, user.api_token !="" %>
- |
- <% end %>
-
- <% end %>
- <% end %>
-
- <%= submit_tag "Update Users" %>
+
+ <%= form_tag( admin_api_update_users_path, method: :put) do %>
+ <% @users.each do |user| %>
+ <% if !user.nil? then%>
+
+ |
+ <% if !user.name.nil? then%>
+ <%= user.name %>
+ <% end %>
+ |
+
+ <%= user.email %>
+ |
+
+ <% if !user.last_sign_in_at.nil? then%>
+ <%= l user.last_sign_in_at.to_date, :formats => :short %>
+ <% end %>
+ |
+
+ <% if !user.project_groups.nil? then%>
+ <%= user.project_groups.length %>
+ <% end %>
+ |
+
+ <%= check_box_tag "org_admin_ids[]", user.id, user.can_org_admin? %>
+ |
+ <% if current_user.organisation.token_permission_types.count > 0 %>
+
+ <%= check_box_tag "api_user_ids[]", user.id, user.api_token !="" %>
+ |
+ <% end %>
+
+ <% end %>
<% end %>
-
\ No newline at end of file
+
+ <%= submit_tag "Update Users" %>
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/users/admin_index.html.erb b/app/views/users/admin_index.html.erb
index 2585634..2881667 100644
--- a/app/views/users/admin_index.html.erb
+++ b/app/views/users/admin_index.html.erb
@@ -5,56 +5,55 @@
<%= raw t('org_admin.user_text_html')%>
-<% @users = current_user.organisation.users %>
-
-
-
- | <%= t('org_admin.user_full_name') %> |
- <%= t('org_admin.user_name') %> |
- <%= t('org_admin.last_logged_in') %> |
- <%= t('org_admin.how_many_plans') %> |
- <%= t('org_admin.is_org_admin') %> |
- <% if current_user.organisation.token_permission_types.count > 0 %>
- <%= t('org_admin.api_privleges') %> |
- <% end %>
-
-
+
+
+
+ | <%= t('org_admin.user_full_name') %> |
+ <%= t('org_admin.user_name') %> |
+ <%= t('org_admin.last_logged_in') %> |
+ <%= t('org_admin.how_many_plans') %> |
+ <%= t('org_admin.is_org_admin') %> |
+ <% if current_user.organisation.token_permission_types.count > 0 %>
+ <%= t('org_admin.api_privleges') %> |
+ <% end %>
+
+
-
- <%= form_tag( admin_api_update_users_path, method: :put) do %>
- <% @users.each do |user| %>
- <% if !user.nil? then%>
-
- |
- <% if !user.name.nil? then%>
- <%= user.name %>
- <% end %>
- |
-
- <%= user.email %>
- |
-
- <% if !user.last_sign_in_at.nil? then%>
- <%= l user.last_sign_in_at.to_date, :formats => :short %>
- <% end %>
- |
-
- <% if !user.project_groups.nil? then%>
- <%= user.project_groups.count %>
- <% end %>
- |
-
- <%= check_box_tag "org_admin_ids[]", user.id, user.can_org_admin? %>
- |
- <% if current_user.organisation.token_permission_types.count > 0 %>
-
- <%= check_box_tag "api_user_ids[]", user.id, user.api_token !="" %>
- |
- <% end %>
-
- <% end %>
- <% end %>
-
- <%= submit_tag "Update Users" %>
+
+ <%= form_tag( admin_api_update_users_path, method: :put) do %>
+ <% @users.each do |user| %>
+ <% if !user.nil? then%>
+
+ |
+ <% if !user.name.nil? then%>
+ <%= user.name %>
+ <% end %>
+ |
+
+ <%= user.email %>
+ |
+
+ <% if !user.last_sign_in_at.nil? then%>
+ <%= l user.last_sign_in_at.to_date, :formats => :short %>
+ <% end %>
+ |
+
+ <% if !user.project_groups.nil? then%>
+ <%= user.project_groups.length %>
+ <% end %>
+ |
+
+ <%= check_box_tag "org_admin_ids[]", user.id, user.can_org_admin? %>
+ |
+ <% if current_user.organisation.token_permission_types.count > 0 %>
+
+ <%= check_box_tag "api_user_ids[]", user.id, user.api_token !="" %>
+ |
+ <% end %>
+
+ <% end %>
<% end %>
-
\ No newline at end of file
+
+ <%= submit_tag "Update Users" %>
+ <% end %>
+
\ No newline at end of file