diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 75f9531..89167fc 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,14 +1,21 @@
class UsersController < ApplicationController
after_action :verify_authorized
+ ##
+ # GET - List of all users for an organisation
+ # Displays number of roles[was project_group], name, email, and last sign in
def admin_index
authorize User
- @users = current_user.org.users.includes(:project_groups)
+ @users = current_user.org.users.includes(:roles)
respond_to do |format|
format.html # index.html.erb
end
end
+ ##
+ # GET - Displays the permissions available to the selected user
+ # Permissions which the user already has are pre-selected
+ # Selecting new permissions and saving calls the admin_update_permissions action
def admin_grant_permissions
@user = User.includes(:perms).find(params[:id])
authorize @user
@@ -16,6 +23,9 @@
@perms = user_perms & Perm.where(name: [constant("user_role_types.change_org_details"),constant("user_role_types.use_api"), constant("user_role_types.modify_guidance"), constant("user_role_types.modify_templates"), constant("user_role_types.grant_permissions")])
end
+ ##
+ # POST - updates the permissions for a user
+ # redirects to the admin_index action
def admin_update_permissions
@user = User.includes(:perms).find(params[:id])
authorize @user
diff --git a/app/views/users/admin_api_update.html.erb b/app/views/users/admin_api_update.html.erb
deleted file mode 100644
index 3f26ec2..0000000
--- a/app/views/users/admin_api_update.html.erb
+++ /dev/null
@@ -1,60 +0,0 @@
-<%= stylesheet_link_tag "admin" %>
-
-
- <%= t('org_admin.users_list') %>
-
-
-<%= 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 %>
-
-
-
-
- <%= 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.is_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" %>
- <% end %>
-
\ No newline at end of file
diff --git a/app/views/users/admin_grant_permissions.html.erb b/app/views/users/admin_grant_permissions.html.erb
index ca5a170..dc42fb1 100644
--- a/app/views/users/admin_grant_permissions.html.erb
+++ b/app/views/users/admin_grant_permissions.html.erb
@@ -9,16 +9,16 @@
- <% @roles.each do |role| %>
- | <%= role.name %> |
+ <% @perms.each do |perm| %>
+ <%= perm.name %> |
<% end %>
- <% @roles.each do |role| %>
+ <% @perms.each do |perm| %>
|
- <%= check_box_tag "role_ids[]", role.id, @user.roles.include?(role) %>
+ <%= check_box_tag "perm_ids[]", perm.id, @user.perms.include?(perm) %>
|
<% end %>
diff --git a/app/views/users/admin_index.html.erb b/app/views/users/admin_index.html.erb
index c914f49..bad7dfc 100644
--- a/app/views/users/admin_index.html.erb
+++ b/app/views/users/admin_index.html.erb
@@ -33,8 +33,8 @@
<% end %>
- <% if !user.project_groups.nil? then%>
- <%= user.project_groups.length %>
+ <% if !user.roles.nil? then%>
+ <%= user.roles.length %>
<% end %>
|
|