Commit a8ef1884f3e2b304934b2e7f91ded6adcbc75412
1 parent
2e30180c
Exists in
staging
and in
42 other branches
users-controller: refactor index action
Showing
1 changed file
with
12 additions
and
16 deletions
Show diff stats
app/controllers/admin/users_controller.rb
| ... | ... | @@ -6,28 +6,18 @@ class UsersController < AdminController |
| 6 | 6 | |
| 7 | 7 | include UsersHelper |
| 8 | 8 | |
| 9 | - def per_page | |
| 10 | - 10 | |
| 11 | - end | |
| 12 | - | |
| 13 | 9 | def index |
| 14 | 10 | @filter = params[:filter] |
| 15 | - if @filter.blank? || @filter == 'all_users' | |
| 16 | - @filter = 'all_users' | |
| 17 | - scope = environment.people.no_templates(environment) | |
| 18 | - elsif @filter == 'admin_users' | |
| 19 | - scope = environment.people.no_templates(environment).admins | |
| 11 | + scope = environment.people.no_templates | |
| 12 | + if @filter == 'admin_users' | |
| 13 | + scope = scope.admins | |
| 20 | 14 | elsif @filter == 'activated_users' |
| 21 | - scope = environment.people.no_templates(environment).activated | |
| 15 | + scope = scope.activated | |
| 22 | 16 | elsif @filter == 'deactivated_users' |
| 23 | - scope = environment.people.no_templates(environment).deactivated | |
| 17 | + scope = scope.deactivated | |
| 24 | 18 | end |
| 25 | 19 | @q = params[:q] |
| 26 | - if @q.blank? | |
| 27 | - @collection = scope.paginate(:per_page => per_page, :page => params[:npage]) | |
| 28 | - else | |
| 29 | - @collection = find_by_contents(:people, scope, @q, {:per_page => per_page, :page => params[:npage]})[:results] | |
| 30 | - end | |
| 20 | + @collection = find_by_contents(:people, scope, @q, {:per_page => per_page, :page => params[:npage]})[:results] | |
| 31 | 21 | end |
| 32 | 22 | |
| 33 | 23 | def set_admin_role |
| ... | ... | @@ -95,4 +85,10 @@ class UsersController < AdminController |
| 95 | 85 | end |
| 96 | 86 | end |
| 97 | 87 | |
| 88 | + private | |
| 89 | + | |
| 90 | + def per_page | |
| 91 | + 10 | |
| 92 | + end | |
| 93 | + | |
| 98 | 94 | end | ... | ... |