[refs #818] refactoring part 3

This commit is contained in:
Alexander Machehin 2013-01-10 22:43:36 +06:00
parent 1427f86b4c
commit ba026c948d
3 changed files with 18 additions and 27 deletions

View File

@ -76,7 +76,7 @@ class Admin::UsersController < Admin::BaseController
@users = @users.send(@filter) if ['real', 'admin', 'banned', 'tester'].include? @filter @users = @users.send(@filter) if ['real', 'admin', 'banned', 'tester'].include? @filter
@users = @users.order(order) @users = @users.order(order)
render :partial => "#{action_name == 'system_list' ? 'system_' : ''}users_ajax", :layout => false render :partial => 'users_ajax', :layout => false
end end
def system_list def system_list

View File

@ -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('&nbsp;|&nbsp;').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

View File

@ -1,17 +1,25 @@
users = @users.map do |user| users = @users.map do |user|
link_block = [ link_block = [
(link_to t('layout.show'), user if can? :read, 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), (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) (link_to t('layout.delete'), admin_user_path(user), :method => :delete, :confirm => t('layout.users.confirm_delete') if can? :destroy, user)
].compact.join('&nbsp;|&nbsp;').html_safe ].compact.join('&nbsp;|&nbsp;').html_safe
[ if action_name == 'list'
user.name, [
user.uname, user.name,
user.email, user.uname,
content_tag(:span, user.role, :style => user.access_locked? ? 'background: #FEDEDE' : ''), user.email,
link_block content_tag(:span, user.role, :style => user.access_locked? ? 'background: #FEDEDE' : ''),
] link_block
]
else
[
user.uname,
link_block
]
end
end end