diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 05045ab12..1ed1581d1 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -36,15 +36,12 @@ class AdminController < ApplicationController scope = Project.status(@status).order('lft') scope = scope.like(params[:name]) if params[:name].present? - @projects = scope.all + @projects = scope.where(project_type: Project::ProjectType_project).all render :action => "projects", :layout => false if request.xhr? end def users - @project_type = params[:project_type] - role = params[:role] - sort_init 'login', 'asc' sort_update %w(login firstname lastname mail admin created_on last_login_on) @@ -56,95 +53,14 @@ class AdminController < ApplicationController end @status = params[:status] || 1 - has = { - "show_changesets" => true - } - # @count = Redmine::Activity::Fetcher.new(User.current, :author => @user).scope_select {|t| !has["show_#{t}"].nil?}.events(nil, nil).count - - scope = UserStatus.visible - case role - when 'teacher' - scope = UserStatus.teacher - when 'student' - scope = UserStatus.student - else - - end - + scope = User.logged.status(@status) + scope = User.like(params[:name]) if params[:name].present? scope = scope.in_group(params[:group_id]) if params[:group_id].present? - # scope.each do |user| - # UserStatus.create(:changesets_count => user.changesets.count, :watchers_count => user.watcher_users.count, :user_id => user.id) - # end + @user_count = scope.count @user_pages = Paginator.new @user_count, @limit, params['page'] - #@offset ||= @user_pages.offset - #@users = scope.order(sort_clause).limit(@limit).offset(@offset).all - @user_base_tag = params[:id] ? 'base_users':'base' - if params[:user_sort_type].present? - case params[:user_sort_type] - when '0' - @offset ||= @user_pages.reverse_offset - unless @offset == 0 - @users_statuses = scope.offset(@offset).limit(@limit).all.reverse - else - limit = @user_count % @limit - if limit == 0 - limit = @limit - end - @users_statuses = scope.offset(@offset).limit(limit).all.reverse - end - @s_type = 0 - # @projects = @projects.sort {|x,y| y.created_on <=> x.created_on } - # @projects = @projects[@offset, @limit] - when '1' - @offset ||= @user_pages.reverse_offset - unless @offset == 0 - @users_statuses = scope.reorder('grade').offset(@offset).limit(@limit).all.reverse - else - limit = @user_count % @limit - if limit == 0 - limit = @limit - end - @users_statuses = scope.reorder('grade').offset(@offset).limit(limit).all.reverse - end - @s_type = 1 - #sort {|x,y| y.user_status.changesets_count <=> x.user_status.changesets_count} - #@users = @users[@offset, @limit] - when '2' - @offset ||= @user_pages.reverse_offset - unless @offset == 0 - @users_statuses = scope.reorder('watchers_count').offset(@offset).limit(@limit).all.reverse - else - limit = @user_count % @limit - if limit == 0 - limit = @limit - end - @users_statuses = scope.reorder('watchers_count').offset(@offset).limit(limit).all.reverse - end - @s_type = 2 - #@users = @users[@offset, @limit] - end - - else - @offset ||= @user_pages.reverse_offset - unless @offset == 0 - @users_statuses = scope.reorder('grade').offset(@offset).limit(@limit).all.reverse - else - limit = @user_count % @limit - if limit == 0 - limit = @limit - end - @users_statuses = scope.reorder('grade').offset(@offset).limit(limit).all.reverse - end - @s_type = 1 - # @projects = @projects.sort {|x,y| y.created_on <=> x.created_on } - # @projects = @projects[@offset, @limit] - end - - @users = [] - @users_statuses.each do |obj| - @users << User.find_by_id("#{obj.user_id}") - end + @offset ||= @user_pages.offset + @users = scope.order(sort_clause).limit(@limit).offset(@offset).all respond_to do |format| @@ -209,24 +125,13 @@ class AdminController < ApplicationController end @status = params[:status] || 1 - has = { - "show_changesets" => true - } scope = User.logged.status(@status) scope = scope.like(params[:name]) if params[:name].present? @user_count = scope.count @user_pages = Paginator.new @user_count, @limit, params['page'] @user_base_tag = params[:id] ? 'base_users':'base' - @offset ||= @user_pages.reverse_offset - unless @offset == 0 - @users = scope.offset(@offset).limit(@limit).all.reverse - else - limit = @user_count % @limit - if limit == 0 - limit = @limit - end - @users = scope.offset(@offset).limit(limit).all.reverse - end + + @users = scope.offset(@user_pages.offset).limit(@user_pages.per_page) respond_to do |format| format.html { diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0ca810cbe..c1f8bba97 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -586,7 +586,7 @@ class UsersController < ApplicationController def destroy @user.destroy respond_to do |format| - format.html { redirect_back_or_default(users_path) } + format.html { redirect_back_or_default(admin_users_path) } format.api { render_api_ok } end end diff --git a/app/views/admin/search.html.erb b/app/views/admin/search.html.erb index 17d91e78b..67c97366e 100644 --- a/app/views/admin/search.html.erb +++ b/app/views/admin/search.html.erb @@ -5,7 +5,7 @@

<%= l(:label_user_plural)%>

- <%= form_tag(:controller => 'admin', :action => 'search', :method => :get) do %> + <%= form_tag(:controller => 'admin', :action => 'search') do %>
<%= l(:label_filter_plural) %> @@ -51,7 +51,7 @@ <%= format_time(user.created_on) %> <%= format_time(user.last_login_on) unless user.last_login_on.nil? %> <%= change_status_link(user) %> - <%= delete_link user_path(user, :back_url => users_path(params)) unless User.current == user %> + <%= delete_link user_path(user, :back_url => admin_users_path(params)) unless User.current == user %> <% end -%> @@ -65,4 +65,4 @@ <% html_title(l(:label_user_plural)) -%> -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/admin/users.html.erb b/app/views/admin/users.html.erb index 4dceb5fd9..41df178d8 100644 --- a/app/views/admin/users.html.erb +++ b/app/views/admin/users.html.erb @@ -5,7 +5,7 @@

<%= l(:label_user_plural)%>

- <%= form_tag(:controller => 'admin', :action => 'search', :method => :get) do %> + <%= form_tag(:controller => 'admin', :action => 'search') do %>
<%= l(:label_filter_plural) %> @@ -51,7 +51,7 @@ <%= format_time(user.created_on) %> <%= format_time(user.last_login_on) unless user.last_login_on.nil? %> <%= change_status_link(user) %> - <%= delete_link user_path(user, :back_url => users_path(params)) unless User.current == user %> + <%= delete_link user_path(user, :back_url => admin_users_path(params)) unless User.current == user %> <% end -%> @@ -66,4 +66,4 @@ <% html_title(l(:label_user_plural)) -%> <%else %> -<% end%> \ No newline at end of file +<% end%>