diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a06618605..9274de730 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -17,9 +17,13 @@ class UsersController < ApplicationController def new @user = User.new + @global_roles = Role.by_acter(User).by_target(:system) + Role.by_acter(:all).by_target(:system) + @global_roles.map! {|role| [role.name, role.id]} end def edit + @global_roles = Role.by_acter(User).by_target(:system) + Role.by_acter(:all).by_target(:system) + @global_roles.map! {|role| [role.name, role.id]} end def create @@ -34,6 +38,7 @@ class UsersController < ApplicationController end def update + puts params[:user].inspect if @user.update_attributes(params[:user]) flash[:notice] = t('flash.user.saved') redirect_to users_path diff --git a/app/models/user.rb b/app/models/user.rb index ac7a909f6..a9eb71bdc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -30,7 +30,7 @@ class User < ActiveRecord::Base errors.add(:uname, I18n.t('flash.user.group_uname_exists')) if Group.exists? :uname => uname } - attr_accessible :email, :password, :password_confirmation, :remember_me, :login, :name, :ssh_key, :uname + attr_accessible :email, :password, :password_confirmation, :remember_me, :login, :name, :ssh_key, :uname, :global_role_id attr_readonly :uname attr_accessor :login diff --git a/app/views/users/_form.html.haml b/app/views/users/_form.html.haml index 582af426e..de6222e76 100644 --- a/app/views/users/_form.html.haml +++ b/app/views/users/_form.html.haml @@ -7,6 +7,9 @@ .group = f.label :email, t("activerecord.attributes.user.email"), :class => :label = f.text_field :email, :class => 'text_field' +.group + = f.label :global_role_id, t("activerecord.attributes.user.global_role"), :class => :label + = f.select :global_role_id, options_for_select(@global_roles, @user.global_role_id) .group = f.label :ssh_key, t("activerecord.attributes.user.ssh_key"), :class => :label = f.text_area :ssh_key, :class => 'text_area' diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index f2876d96c..0ea9ad5fc 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -21,6 +21,11 @@ = t("activerecord.attributes.user.email") \: = @user.email + %p + %b + = t("activerecord.attributes.user.global_role") + \: + = @user.global_role.name %p %b = t("activerecord.attributes.user.created_at")