summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJose Ivan Vargas <jvargas@gitlab.com>2017-02-06 15:38:08 -0600
committerJose Ivan Vargas <jvargas@gitlab.com>2017-02-06 16:17:46 -0600
commit426680def4bdeb7c6b37d8a0538fc73c39942495 (patch)
tree573425c39c4391f1c533801bcf9cbecfe3a4e740 /app
parent54ff60f7064b4287ce3727c9a6f373a77b03ef5f (diff)
downloadgitlab-ce-426680def4bdeb7c6b37d8a0538fc73c39942495.tar.gz
Backport of the frontend view, including tests
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/users_controller.rb2
-rw-r--r--app/models/user.rb15
-rw-r--r--app/views/admin/users/_access_levels.html.haml18
3 files changed, 28 insertions, 7 deletions
diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
index aa0f8d434dc..1cd50852e89 100644
--- a/app/controllers/admin/users_controller.rb
+++ b/app/controllers/admin/users_controller.rb
@@ -175,7 +175,7 @@ class Admin::UsersController < Admin::ApplicationController
def user_params_ce
[
- :admin,
+ :access_level,
:avatar,
:bio,
:can_create_group,
diff --git a/app/models/user.rb b/app/models/user.rb
index 54f5388eb2c..79c83f7bcf4 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -903,6 +903,21 @@ class User < ActiveRecord::Base
end
end
+ def access_level
+ if admin?
+ :admin
+ else
+ :regular
+ end
+ end
+
+ def access_level=(new_level)
+ new_level = new_level.to_s
+ return unless %w(admin regular).include?(new_level)
+
+ self.admin = (new_level == 'admin')
+ end
+
private
def ci_projects_union
diff --git a/app/views/admin/users/_access_levels.html.haml b/app/views/admin/users/_access_levels.html.haml
index 81337db3aae..18fdb1435a9 100644
--- a/app/views/admin/users/_access_levels.html.haml
+++ b/app/views/admin/users/_access_levels.html.haml
@@ -9,12 +9,18 @@
.col-sm-10= f.check_box :can_create_group
.form-group
- = f.label :admin, class: 'control-label'
- - if current_user == @user
- .col-sm-10= f.check_box :admin, disabled: true
- .col-sm-10 You cannot remove your own admin rights.
- - else
- .col-sm-10= f.check_box :admin
+ = f.label :access_level, class: 'control-label'
+ .col-sm-10
+ = f.radio_button :access_level, :regular, disabled: (current_user == @user && @user.is_admin?)
+ = label_tag :regular do
+ Regular
+ %p.light
+ Regular users have access to their groups and projects
+ = f.radio_button :access_level, :admin
+ = label_tag :admin do
+ Admin
+ %p.light
+ Administrators have access to all groups, projects and users and can manage all features in this installation
.form-group
= f.label :external, class: 'control-label'