Fix not_in_project scope. Added counters in admin -> users. Improved seeds
This commit is contained in:
parent
e56a47ab19
commit
4cbb29cfad
13 changed files with 103 additions and 57 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue