From ba026c948df3d2ae2ad594ad546597cdcefb58c5 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Thu, 10 Jan 2013 22:43:36 +0600 Subject: [PATCH] [refs #818] refactoring part 3 --- app/controllers/admin/users_controller.rb | 2 +- .../users/_system_users_ajax.json.jbuilder | 17 ------------ .../admin/users/_users_ajax.json.jbuilder | 26 ++++++++++++------- 3 files changed, 18 insertions(+), 27 deletions(-) delete mode 100644 app/views/admin/users/_system_users_ajax.json.jbuilder diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index ca8480398..2db5b4f11 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -76,7 +76,7 @@ class Admin::UsersController < Admin::BaseController @users = @users.send(@filter) if ['real', 'admin', 'banned', 'tester'].include? @filter @users = @users.order(order) - render :partial => "#{action_name == 'system_list' ? 'system_' : ''}users_ajax", :layout => false + render :partial => 'users_ajax', :layout => false end def system_list diff --git a/app/views/admin/users/_system_users_ajax.json.jbuilder b/app/views/admin/users/_system_users_ajax.json.jbuilder deleted file mode 100644 index 21056c467..000000000 --- a/app/views/admin/users/_system_users_ajax.json.jbuilder +++ /dev/null @@ -1,17 +0,0 @@ -users = @users.map do |user| - link_block = [ - (link_to t('layout.users.reset_token'), reset_auth_token_admin_user_path(user), :method => :put, :confirm => t('layout.users.confirm_reset_token') if can? :edit, user), - (link_to t('layout.delete'), admin_user_path(user), :method => :delete, :confirm => t('layout.users.confirm_delete') if can? :destroy, user) - ].compact.join(' | ').html_safe - - [ - user.uname, - link_block - ] -end - - -json.sEcho params[:sEcho].to_i || -1 -json.iTotalRecords @total_users -json.iTotalDisplayRecords @users.count -json.aaData users diff --git a/app/views/admin/users/_users_ajax.json.jbuilder b/app/views/admin/users/_users_ajax.json.jbuilder index f595d528d..d2eb160ef 100644 --- a/app/views/admin/users/_users_ajax.json.jbuilder +++ b/app/views/admin/users/_users_ajax.json.jbuilder @@ -1,17 +1,25 @@ users = @users.map do |user| link_block = [ - (link_to t('layout.show'), user if can? :read, user), - (link_to t('layout.edit'), edit_admin_user_path(user) if can? :edit, user), + (link_to t('layout.show'), user if can?(:read, user) && action_name == 'list'), + (link_to t('layout.edit'), edit_admin_user_path(user) if can?(:edit, user) && action_name == 'list'), + (link_to t('layout.users.reset_token'), reset_auth_token_admin_user_path(user), :method => :put, :confirm => t('layout.users.confirm_reset_token') if can?(:edit, user) && action_name == 'system_list'), (link_to t('layout.delete'), admin_user_path(user), :method => :delete, :confirm => t('layout.users.confirm_delete') if can? :destroy, user) ].compact.join(' | ').html_safe - [ - user.name, - user.uname, - user.email, - content_tag(:span, user.role, :style => user.access_locked? ? 'background: #FEDEDE' : ''), - link_block - ] + if action_name == 'list' + [ + user.name, + user.uname, + user.email, + content_tag(:span, user.role, :style => user.access_locked? ? 'background: #FEDEDE' : ''), + link_block + ] + else + [ + user.uname, + link_block + ] + end end