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

Create `copy_work_packages` permission

Aaron Contreras9869d4f49efb
diff --git a/app/seeders/common.yml b/app/seeders/common.yml
index c7bd9f6fdea..3b6804c5947 100644
--- a/app/seeders/common.yml
+++ b/app/seeders/common.yml
@@ -250,6 +250,7 @@ work_package_roles:
- :add_work_package_notes
- :edit_own_work_package_notes
- :manage_work_package_relations
+ - :copy_work_packages
- :export_work_packages
- reference: :default_role_work_package_commenter
t_name: Work Package Commenter
diff --git a/config/initializers/permissions.rb b/config/initializers/permissions.rb
index 7c4123ebf16..e6fbeb3bc79 100644
--- a/config/initializers/permissions.rb
+++ b/config/initializers/permissions.rb
@@ -174,6 +174,11 @@ Rails.application.reloader.to_prepare do
dependencies: :view_work_packages,
contract_actions: { work_packages: %i[move] }
+ wpt.permission :copy_work_packages,
+ {},
+ require: :loggedin,
+ permissible_on: %i[work_package project],
+ dependencies: :view_work_packages
wpt.permission :add_work_package_notes,
{
# FIXME: Although the endpoint is removed, the code checking whether a user
diff --git a/config/locales/en.yml b/config/locales/en.yml
index d5e5657e737..57133b3690d 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2446,6 +2446,7 @@ en:
permission_comment_news: "Comment news"
permission_commit_access: "Read/write access to repository (commit)"
permission_copy_projects: "Copy projects"
+ permission_copy_work_packages: "Copy work packages"
permission_create_backup: "Create backup"
permission_delete_work_package_watchers: "Delete watchers"
permission_delete_work_packages: "Delete work packages"
diff --git a/db/migrate/20230829151629_add_copy_work_packages_permission_to_roles.rb b/db/migrate/20230829151629_add_copy_work_packages_permission_to_roles.rb
new file mode 100644
index 00000000000..fc6c0bd8e66
--- /dev/null
+++ b/db/migrate/20230829151629_add_copy_work_packages_permission_to_roles.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-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.
+#++
+
+require_relative 'migration_utils/permission_adder'
+
+class AddCopyWorkPackagesPermissionToRoles < ActiveRecord::Migration[7.0]
+ # Decouple ActiveRecord model from Migration
+ class MigrationRolePermission < ApplicationRecord
+ self.table_name = 'role_permissions'
+ end
+
+ def up
+ ::Migration::MigrationUtils::PermissionAdder
+ .add(:move_work_packages,
+ :copy_work_packages)
+ end
+
+ def down
+ MigrationRolePermission.where(permission: 'copy_work_packages').delete_all
+ end
+end