From c76adc189651e4ae31e200fae06251728756aebc Mon Sep 17 00:00:00 2001 From: Spen Date: Fri, 18 Oct 2013 19:02:14 +0800 Subject: [PATCH] new ui member account privilege fix --- .../admin/users_new_interface_controller.rb | 12 ++++++++++++ app/views/admin/users_new_interface/show.html.erb | 2 +- config/locales/en.yml | 3 ++- config/routes.rb | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/users_new_interface_controller.rb b/app/controllers/admin/users_new_interface_controller.rb index 188cc24b..77045ed3 100644 --- a/app/controllers/admin/users_new_interface_controller.rb +++ b/app/controllers/admin/users_new_interface_controller.rb @@ -275,6 +275,18 @@ class Admin::UsersNewInterfaceController < OrbitMemberController render :action => :setting_account, :notice => flash.now[:error] end + elsif params[:edit_type] == 'edit_privilege' + + if @user.admin && current_user.id == @user.id + flash.now[:error] = t("users.admin_change_password") + end + + if !flash.now[:error] && @user.update_attributes(params[:user]) + redirect_to :action => :show + else + render :action => :edit_privilege, :notice => flash.now[:error] + end + else @user.update_attributes(params[:user]) diff --git a/app/views/admin/users_new_interface/show.html.erb b/app/views/admin/users_new_interface/show.html.erb index a57752de..a87e4ee2 100644 --- a/app/views/admin/users_new_interface/show.html.erb +++ b/app/views/admin/users_new_interface/show.html.erb @@ -20,8 +20,8 @@ <%= @user.email %>
<%= link_to(" #{t(:edit)}".html_safe,edit_admin_users_new_interface_path(@user),:class=>"btn btn-mini" ) if is_admin?%> - <%= link_to(" #{t("users.change_passwd")}".html_safe,admin_users_new_interface_edit_passwd_path(@user),:class=>"btn btn-mini" ) if is_admin? and current_user.id != @user.id %> + <%= link_to(" #{t("users.setting_privilege")}".html_safe,admin_users_new_interface_edit_privilege_path(@user),:class=>"btn btn-mini" ) if is_admin? and current_user.id != @user.id %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index 00b5e38c..9ddf81f5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -486,7 +486,8 @@ en: users: admin_change_password: You cannot change your own password here! avatar: Profile Picture - change_passwd: Change Password + change_passwd: Password + setting_privilege: Privilege email: Email first_name: First Name last_name: Last Name diff --git a/config/routes.rb b/config/routes.rb index 0e060d34..6c71cf70 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -221,6 +221,7 @@ Orbit::Application.routes.draw do match "edit_passwd" => "users_new_interface#edit_passwd" ,:as => :edit_passwd match "edit_user_data" => "users_new_interface#edit_user_data" ,:as => :edit_user_data match "setting_account" => "users_new_interface#setting_account" ,:as => :setting_account + match "edit_privilege" => "users_new_interface#edit_privilege" ,:as => :edit_privilege end resources :member_selects do