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
Use allowed_in_work_package? check in WorkPackage API
Klaus Zandersa7277bfe637b
diff --git a/lib/api/v3/custom_actions/custom_actions_api.rb b/lib/api/v3/custom_actions/custom_actions_api.rbindex e5b56232d4f..8bff2f26dbc 100644--- a/lib/api/v3/custom_actions/custom_actions_api.rb+++ b/lib/api/v3/custom_actions/custom_actions_api.rb@@ -41,7 +41,7 @@ module APIhelpers ::API::V3::WorkPackages::WorkPackagesSharedHelpersafter_validation do- authorize_in_any_project(:edit_work_packages)+ authorize_in_any_work_package(:edit_work_packages)endget dodiff --git a/lib/api/v3/work_packages/available_projects_on_edit_api.rb b/lib/api/v3/work_packages/available_projects_on_edit_api.rbindex c564342bae4..f2d6987a0e6 100644--- a/lib/api/v3/work_packages/available_projects_on_edit_api.rb+++ b/lib/api/v3/work_packages/available_projects_on_edit_api.rb@@ -32,7 +32,7 @@ module APIclass AvailableProjectsOnEditAPI < ::API::OpenProjectAPIresource :available_projects doafter_validation do- authorize_in_project(:edit_work_packages, project: @work_package.project)+ authorize_in_work_package(:edit_work_packages, work_package: @work_package.project)checked_permissions = Projects::ProjectCollectionRepresenter.checked_permissionscurrent_user.preload_projects_allowed_to(checked_permissions)diff --git a/lib/api/v3/work_packages/create_project_form_representer.rb b/lib/api/v3/work_packages/create_project_form_representer.rbindex f0f15973949..1b308839b77 100644--- a/lib/api/v3/work_packages/create_project_form_representer.rb+++ b/lib/api/v3/work_packages/create_project_form_representer.rb@@ -52,7 +52,7 @@ module APIendlink :commit do- if current_user.allowed_in_project?(:edit_work_packages, represented.project) &&+ if current_user.allowed_in_work_package?(:edit_work_packages, represented) &&@errors.empty?{href: api_v3_paths.work_packages_by_project(represented.project_id),diff --git a/lib/api/v3/work_packages/update_form_representer.rb b/lib/api/v3/work_packages/update_form_representer.rbindex 764e10960ee..1421bbd9c8c 100644--- a/lib/api/v3/work_packages/update_form_representer.rb+++ b/lib/api/v3/work_packages/update_form_representer.rb@@ -52,7 +52,7 @@ module APIendlink :commit do- if current_user.allowed_in_project?(:edit_work_packages, represented.project) &&+ if current_user.allowed_in_work_package?(:edit_work_packages, represented) &&@errors.empty?{href: api_v3_paths.work_package(represented.id),diff --git a/lib/api/v3/work_packages/work_package_collection_representer.rb b/lib/api/v3/work_packages/work_package_collection_representer.rbindex 95242fed8c3..e52146616cd 100644--- a/lib/api/v3/work_packages/work_package_collection_representer.rb+++ b/lib/api/v3/work_packages/work_package_collection_representer.rb@@ -187,9 +187,9 @@ module APIdef current_user_allowed_to_edit_work_packages?if project- current_user.allowed_in_project?(:edit_work_packages, project)+ current_user.allowed_in_any_work_package?(:edit_work_packages, in_project: project)else- current_user.allowed_in_any_project?(:edit_work_packages)+ current_user.allowed_in_any_work_package?(:edit_work_packages)endenddiff --git a/lib/api/v3/work_packages/work_package_representer.rb b/lib/api/v3/work_packages/work_package_representer.rbindex 608e7809a6e..707649165a4 100644--- a/lib/api/v3/work_packages/work_package_representer.rb+++ b/lib/api/v3/work_packages/work_package_representer.rb@@ -566,20 +566,20 @@ module APIdef current_user_update_allowed?@current_user_update_allowed ||=- current_user.allowed_in_project?(:edit_work_packages, represented.project) ||+ current_user.allowed_in_work_package?(:edit_work_packages, represented) ||current_user.allowed_in_project?(:assign_versions, represented.project)enddef view_time_entries_allowed?@view_time_entries_allowed ||=current_user.allowed_in_project?(:view_time_entries, represented.project) ||- current_user.allowed_in_project?(:view_own_time_entries, represented.project)+ current_user.allowed_in_work_package?(:view_own_time_entries, represented)enddef log_time_allowed?@log_time_allowed ||=current_user.allowed_in_project?(:log_time, represented.project) ||- current_user.allowed_in_project?(:log_own_time, represented.project)+ current_user.allowed_in_work_package?(:log_own_time, represented)enddef view_budgets_allowed?@@ -588,7 +588,7 @@ module APIdef export_work_packages_allowed?@export_work_packages_allowed ||=- current_user.allowed_in_project?(:export_work_packages, represented.project)+ current_user.allowed_in_work_package?(:export_work_packages, represented)enddef add_work_packages_allowed?