Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add a new scope to find projects with work packages the user is allowed to see

Klaus Zanders833d117372d2
diff --git a/app/models/project.rb b/app/models/project.rb
index 23f0847c243..a404365dd5a 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -157,6 +157,9 @@ class Project < ApplicationRecord
}
scope :public_projects, -> { where(public: true) }
scope :visible, ->(user = User.current) { where(id: Project.visible_by(user)) }
+ scope :with_visible_work_packages, ->(user = User.current) do
+ where(id: WorkPackage.visible(user).select(:project_id))
+ end
scope :newest, -> { order(created_at: :desc) }
scope :active, -> { where(active: true) }
scope :archived, -> { where(active: false) }