Commit 426680de authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Backport of the frontend view, including tests

parent 54ff60f7
...@@ -175,7 +175,7 @@ class Admin::UsersController < Admin::ApplicationController ...@@ -175,7 +175,7 @@ class Admin::UsersController < Admin::ApplicationController
def user_params_ce def user_params_ce
[ [
:admin, :access_level,
:avatar, :avatar,
:bio, :bio,
:can_create_group, :can_create_group,
......
...@@ -903,6 +903,21 @@ class User < ActiveRecord::Base ...@@ -903,6 +903,21 @@ class User < ActiveRecord::Base
end end
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 private
def ci_projects_union def ci_projects_union
......
...@@ -9,12 +9,18 @@ ...@@ -9,12 +9,18 @@
.col-sm-10= f.check_box :can_create_group .col-sm-10= f.check_box :can_create_group
.form-group .form-group
= f.label :admin, class: 'control-label' = f.label :access_level, class: 'control-label'
- if current_user == @user .col-sm-10
.col-sm-10= f.check_box :admin, disabled: true = f.radio_button :access_level, :regular, disabled: (current_user == @user && @user.is_admin?)
.col-sm-10 You cannot remove your own admin rights. = label_tag :regular do
- else Regular
.col-sm-10= f.check_box :admin %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 .form-group
= f.label :external, class: 'control-label' = f.label :external, class: 'control-label'
......
...@@ -211,7 +211,7 @@ describe "Admin::Users", feature: true do ...@@ -211,7 +211,7 @@ describe "Admin::Users", feature: true do
fill_in "user_email", with: "bigbang@mail.com" fill_in "user_email", with: "bigbang@mail.com"
fill_in "user_password", with: "AValidPassword1" fill_in "user_password", with: "AValidPassword1"
fill_in "user_password_confirmation", with: "AValidPassword1" fill_in "user_password_confirmation", with: "AValidPassword1"
check "user_admin" choose "user_access_level_admin"
click_button "Save changes" click_button "Save changes"
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment