diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/user.rb | 9 | ||||
-rw-r--r-- | app/views/admin/projects/index.html.haml | 2 | ||||
-rw-r--r-- | app/views/admin/users/index.html.haml | 9 |
3 files changed, 16 insertions, 4 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 1bc070f040d..c2486fd3a16 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -77,7 +77,6 @@ class User < ActiveRecord::Base delegate :path, to: :namespace, allow_nil: true, prefix: true # Scopes - scope :not_in_project, ->(project) { where("id not in (:ids)", ids: project.users.map(&:id) ) } scope :admins, where(admin: true) scope :blocked, where(blocked: true) scope :active, where(blocked: false) @@ -93,6 +92,14 @@ class User < ActiveRecord::Base end end + def not_in_project(project) + if project.users.present? + where("id not in (:ids)", ids: project.users.map(&:id) ) + else + scoped + end + end + def without_projects where('id NOT IN (SELECT DISTINCT(user_id) FROM users_projects)') end diff --git a/app/views/admin/projects/index.html.haml b/app/views/admin/projects/index.html.haml index 310cfa53890..0b9f91f7a5f 100644 --- a/app/views/admin/projects/index.html.haml +++ b/app/views/admin/projects/index.html.haml @@ -1,5 +1,5 @@ %h3.page_title - Projects (#{@projects.count}) + Projects (#{Project.count}) = link_to 'New Project', new_project_path, class: "btn small right" %br = form_tag admin_projects_path, method: :get, class: 'form-inline' do diff --git a/app/views/admin/users/index.html.haml b/app/views/admin/users/index.html.haml index 1df4f590bcb..87290abe7a6 100644 --- a/app/views/admin/users/index.html.haml +++ b/app/views/admin/users/index.html.haml @@ -1,5 +1,5 @@ %h3.page_title - Users (#{@admin_users.count}) + Users = link_to 'New User', new_admin_user_path, class: "btn small right" %br @@ -8,16 +8,21 @@ = submit_tag "Search", class: "btn submit primary" %ul.nav.nav-tabs %li{class: "#{'active' unless params[:filter]}"} - = link_to "Active", admin_users_path + = link_to admin_users_path do + Active + %span.badge= User.active.count %li{class: "#{'active' if params[:filter] == "admins"}"} = link_to admin_users_path(filter: "admins") do Admins + %span.badge= User.admins.count %li{class: "#{'active' if params[:filter] == "blocked"}"} = link_to admin_users_path(filter: "blocked") do Blocked + %span.badge= User.blocked.count %li{class: "#{'active' if params[:filter] == "wop"}"} = link_to admin_users_path(filter: "wop") do Without projects + %span.badge= User.without_projects.count %table %thead |