Change and fix role assign logic and abilities. Other minor fixes. Refs #2261
This commit is contained in:
parent
b98453bd62
commit
366ca320e0
|
@ -35,7 +35,7 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def update
|
||||
@user.role = params[:user][:role] if current_user.admin?
|
||||
@user.role = params[:user][:role]
|
||||
if @user.update_attributes(params[:user])
|
||||
flash[:notice] = t('flash.user.saved')
|
||||
redirect_to users_path
|
||||
|
|
|
@ -27,8 +27,7 @@ class Ability
|
|||
can :index, AutoBuildList
|
||||
# If rules goes one by one CanCan joins them by 'OR' sql operator
|
||||
can :read, Project, :visibility => 'open'
|
||||
# User can read and edit his profile:
|
||||
can :manage, User, :id => user.id
|
||||
can :read, User
|
||||
can :manage_collaborators, Project do |project|
|
||||
project.relations.exists? :object_id => user.id, :object_type => 'User', :role => 'admin'
|
||||
end
|
||||
|
|
|
@ -30,12 +30,6 @@
|
|||
.right
|
||||
= f.text_area :ssh_key, :class => "text_area"
|
||||
|
||||
.group.wat-cf
|
||||
.left
|
||||
= f.label :role, t("activerecord.attributes.user.role"), :class => :label
|
||||
.right
|
||||
= f.select :role, User::ROLES.push("")
|
||||
|
||||
/ .group.wat-cf
|
||||
/ .left
|
||||
/ = f.label :current_password, :class => "label"
|
||||
|
|
|
@ -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 :role, t("activerecord.attributes.user.role"), :class => :label
|
||||
= f.select :role, User::ROLES, :include_blank => true
|
||||
.group
|
||||
= f.label :ssh_key, t("activerecord.attributes.user.ssh_key"), :class => :label
|
||||
= f.text_area :ssh_key, :class => 'text_area'
|
||||
|
|
|
@ -27,8 +27,10 @@
|
|||
\:
|
||||
= @user.created_at
|
||||
.wat-cf
|
||||
= link_to image_tag("web-app-theme/icons/application_edit.png", :alt => t("layout.edit")) + " " + t("layout.edit"), edit_user_path(@user), :class => "button"
|
||||
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), user_path(@user), :method => "delete", :class => "button", :confirm => t("layout.users.confirm_delete")
|
||||
- if can? :edit, @user
|
||||
= link_to image_tag("web-app-theme/icons/application_edit.png", :alt => t("layout.edit")) + " " + t("layout.edit"), edit_user_path(@user), :class => "button"
|
||||
- if can? :destroy, @user
|
||||
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), user_path(@user), :method => "delete", :class => "button", :confirm => t("layout.users.confirm_delete")
|
||||
|
||||
.block
|
||||
.secondary-navigation
|
||||
|
|
|
@ -536,7 +536,7 @@ ru:
|
|||
uname: Никнейм
|
||||
ssh_key: SSH ключ
|
||||
current_password: Текущий пароль
|
||||
roles: Роли
|
||||
role: Роль
|
||||
created_at: Создан
|
||||
updated_at: Обновлен
|
||||
global_role: Роль в системе
|
||||
|
|
Loading…
Reference in New Issue