Backport of the frontend view, including tests
This commit is contained in:
parent
54ff60f706
commit
426680def4
4 changed files with 29 additions and 8 deletions
|
@ -175,7 +175,7 @@ class Admin::UsersController < Admin::ApplicationController
|
|||
|
||||
def user_params_ce
|
||||
[
|
||||
:admin,
|
||||
:access_level,
|
||||
:avatar,
|
||||
:bio,
|
||||
:can_create_group,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -211,7 +211,7 @@ describe "Admin::Users", feature: true do
|
|||
fill_in "user_email", with: "bigbang@mail.com"
|
||||
fill_in "user_password", with: "AValidPassword1"
|
||||
fill_in "user_password_confirmation", with: "AValidPassword1"
|
||||
check "user_admin"
|
||||
choose "user_access_level_admin"
|
||||
click_button "Save changes"
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue