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

Fix scope to also work if no work package exists

Klaus Zandersaf5af7373deb
diff --git a/app/models/project.rb b/app/models/project.rb
index a404365dd5a..744aab02073 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -158,7 +158,7 @@ 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))
+ where(id: WorkPackage.visible(user).select(:project_id)).or(allowed_to(user, :view_work_packages))
end
scope :newest, -> { order(created_at: :desc) }
scope :active, -> { where(active: true) }