Skip to content
Snippets Groups Projects
Commit 426680de authored by Jose Ivan Vargas Lopez's avatar Jose Ivan Vargas Lopez
Browse files

Backport of the frontend view, including tests

parent 54ff60f7
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -175,7 +175,7 @@ class Admin::UsersController < Admin::ApplicationController
 
def user_params_ce
[
:admin,
:access_level,
:avatar,
:bio,
:can_create_group,
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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'
Loading
Loading
Loading
Loading
@@ -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
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment