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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
extract into scopes
ulfertsd89cf6eaaa5b
diff --git a/app/controllers/work_packages/shares_controller.rb b/app/controllers/work_packages/shares_controller.rbindex 8a3b8502d64..20873d2ef99 100644--- a/app/controllers/work_packages/shares_controller.rb+++ b/app/controllers/work_packages/shares_controller.rb@@ -79,8 +79,7 @@ class WorkPackages::SharesController < ApplicationControllerenddef find_share- # TODO: move into scope- @share = Member.where(entity_type: WorkPackage.name).find(params[:id])+ @share = Member.of_work_packages.find(params[:id])@work_package = @share.entityenddiff --git a/app/models/member.rb b/app/models/member.rbindex 8f41d70f580..eb9887e18d5 100644--- a/app/models/member.rb+++ b/app/models/member.rb@@ -52,6 +52,8 @@ class Member < ApplicationRecord:global,:not_locked,:of,+ :of_work_package,+ :of_work_packages,:visibledelegate :name, to: :principaldiff --git a/app/models/members/scopes/of.rb b/app/models/members/scopes/of.rbindex ba70545a59b..7d3f225d63b 100644--- a/app/models/members/scopes/of.rb+++ b/app/models/members/scopes/of.rb@@ -35,11 +35,6 @@ module Members::Scopesdef of(project)where(project_id: project)end-- # Find all users, that are member of a specific Work Package- def of_work_package(work_package)- where(entity: work_package)- endendendenddiff --git a/app/models/members/scopes/of_work_package.rb b/app/models/members/scopes/of_work_package.rbnew file mode 100644index 00000000000..e316a9ba4da--- /dev/null+++ b/app/models/members/scopes/of_work_package.rb@@ -0,0 +1,40 @@+# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2010-2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++module Members::Scopes+ module OfWorkPackage+ extend ActiveSupport::Concern++ class_methods do+ # Find all members of a specific Work Package+ def of_work_package(work_package)+ where(entity: work_package)+ end+ end+ end+enddiff --git a/app/models/members/scopes/of_work_packages.rb b/app/models/members/scopes/of_work_packages.rbnew file mode 100644index 00000000000..4c2e4ac5937--- /dev/null+++ b/app/models/members/scopes/of_work_packages.rb@@ -0,0 +1,40 @@+# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2010-2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++module Members::Scopes+ module OfWorkPackages+ extend ActiveSupport::Concern++ class_methods do+ # Find all members relating to any work package+ def of_work_packages+ where(entity_type: WorkPackage.name)+ end+ end+ end+end