mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-16 14:17:00 +08:00
added scope functionality
This commit is contained in:
parent
e1ab7bda4b
commit
e381651df2
2 changed files with 6 additions and 1 deletions
|
@ -71,6 +71,11 @@ class Project < ApplicationRecord
|
|||
end
|
||||
end)
|
||||
|
||||
scope :not_assigned_to_user, lambda { |user|
|
||||
left_joins(:user_assignments)
|
||||
.where('user_assignments.user_id = ? AND user_assignments.id IS NULL', user.id)
|
||||
}
|
||||
|
||||
scope :templates, -> { where(template: true) }
|
||||
|
||||
after_create :auto_assign_project_members, if: :visible?
|
||||
|
|
|
@ -13,7 +13,7 @@ module Toolbars
|
|||
@project_folders = current_user.current_team.project_folders.where(id: project_folder_ids)
|
||||
|
||||
@items = @projects + @project_folders
|
||||
@not_assigned = @projects.any? { |project| !project.assigned_users.include?(current_user) }
|
||||
@not_assigned = current_user.current_team.projects.not_assigned_to_user(current_user).any?
|
||||
|
||||
@single = @items.length == 1
|
||||
|
||||
|
|
Loading…
Reference in a new issue