From f7b180169327ae54b6d295536211a983d3b0620d Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 29 May 2013 14:43:40 +0400 Subject: [PATCH] #136: added created field to Admin/users page --- app/controllers/admin/users_controller.rb | 6 +++--- app/views/admin/users/_users_ajax.json.jbuilder | 4 ++-- app/views/admin/users/index.html.haml | 3 ++- config/locales/users.en.yml | 1 + config/locales/users.ru.yml | 1 + 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 09e1089f2..2f9a842bb 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -58,13 +58,13 @@ class Admin::UsersController < Admin::BaseController def list if params[:system] != 'true' - colName, @users = ['users.name', 'users.uname', 'users.email'], @users.opened + colName, @users = %w(name uname email created_at), @users.opened else - colName, @users, @system_list = ['users.uname'], @users.system, true + colName, @users, @system_list = ['uname'], @users.system, true end sort_col = params[:iSortCol_0] || 0 sort_dir = params[:sSortDir_0]=="asc" ? 'asc' : 'desc' - order = "#{colName[sort_col.to_i]} #{sort_dir}" + order = "users.#{colName[sort_col.to_i]} #{sort_dir}" @users = @users.paginate(:page => (params[:iDisplayStart].to_i/params[:iDisplayLength].to_i).to_i + 1, :per_page => params[:iDisplayLength]) @total_users = @users.count diff --git a/app/views/admin/users/_users_ajax.json.jbuilder b/app/views/admin/users/_users_ajax.json.jbuilder index 052003e36..363e968da 100644 --- a/app/views/admin/users/_users_ajax.json.jbuilder +++ b/app/views/admin/users/_users_ajax.json.jbuilder @@ -1,6 +1,5 @@ users = @users.map do |user| link_block = [ - (link_to t('layout.show'), user if can?(:read, user) && !@system_list), (link_to t('layout.edit'), edit_admin_user_path(user) if can?(:edit, user) && !@system_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) && @system_list), (link_to t('layout.delete'), admin_user_path(user), :method => :delete, :confirm => t('layout.users.confirm_delete') if can? :destroy, user) @@ -9,8 +8,9 @@ users = @users.map do |user| if !@system_list [ user.name, - user.uname, + (can?(:read, user) ? link_to(user.uname, user) : user.uname), user.email, + user.created_at.to_date, content_tag(:span, user.role, :style => user.access_locked? ? 'background: #FEDEDE' : ''), link_block ] diff --git a/app/views/admin/users/index.html.haml b/app/views/admin/users/index.html.haml index 2ccbc25d6..632b16c10 100644 --- a/app/views/admin/users/index.html.haml +++ b/app/views/admin/users/index.html.haml @@ -2,7 +2,7 @@ -if @filter == 'system' - columns = [{:type => 'html'}, {:type => nil, :sortable => false, :searchable => false, :class => 'buttons'}] -else - - columns = [{:type => 'html'}, {:type => 'html'}, {:type => 'html'}, {:type => 'html', :sortable => false, :searchable => false}, {:type => nil, :sortable => false, :searchable => false, :class => 'buttons'}] + - columns = [{:type => 'html'}, {:type => 'html'}, {:type => 'html'}, {:type => 'html'}, {:type => 'html', :sortable => false, :searchable => false}, {:type => nil, :sortable => false, :searchable => false, :class => 'buttons'}] = raw datatable(columns, {:sort_by => "[0, 'asc']", :processing => t("layout.processing"), :search_label => t("layout.search.header"), :pagination_labels => {:previous => t("datatables.previous_label"), :next => t("datatables.next_label")}, :empty_label => t("datatables.empty_label"), @@ -23,6 +23,7 @@ %th.th1= t("activerecord.attributes.user.name") %th.th2= t("activerecord.attributes.user.uname") %th.th3= t("activerecord.attributes.user.email") + %th.th1= t("activerecord.attributes.user.created_at") %th.th4= t("activerecord.attributes.user.role") %th.last   %tbody diff --git a/config/locales/users.en.yml b/config/locales/users.en.yml index b910b21f6..ba36f5053 100644 --- a/config/locales/users.en.yml +++ b/config/locales/users.en.yml @@ -37,6 +37,7 @@ en: login: Nickname or Email email: Email uname: Nickname + created_at: Created ssh_key: SSH key current_password: Current password role: Role diff --git a/config/locales/users.ru.yml b/config/locales/users.ru.yml index bd30181e5..64dc06eda 100644 --- a/config/locales/users.ru.yml +++ b/config/locales/users.ru.yml @@ -37,6 +37,7 @@ ru: login: Псевдоним или Email email: Email uname: Никнейм + created_at: Создан ssh_key: SSH ключ current_password: Текущий пароль role: Роль