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

Use the correct filter for linking to time entries

Klaus Zanders5ee9642795c3
diff --git a/lib/api/v3/work_packages/work_package_representer.rb b/lib/api/v3/work_packages/work_package_representer.rb
index acf460e349e..ea21abee85d 100644
--- a/lib/api/v3/work_packages/work_package_representer.rb
+++ b/lib/api/v3/work_packages/work_package_representer.rb
@@ -308,7 +308,10 @@ module API
cache_if: -> { view_time_entries_allowed? } do
next if represented.new_record?
- filters = [{ work_package_id: { operator: "=", values: [represented.id.to_s] } }]
+ filters = [
+ { entity_type: { operator: "=", values: ["WorkPackage"] } },
+ { entity_id: { operator: "=", values: [represented.id.to_s] } }
+ ]
{
href: api_v3_paths.path_for(:time_entries, filters:),
@@ -672,10 +675,10 @@ module API
@view_own_time_entries_allowed = if represented.new_record?
current_user.allowed_in_any_work_package?(:view_own_time_entries,
- in_project: represented.project)
- else
- current_user.allowed_in_work_package?(:view_own_time_entries, represented)
- end
+ in_project: represented.project)
+ else
+ current_user.allowed_in_work_package?(:view_own_time_entries, represented)
+ end
end
def log_time_allowed?
diff --git a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_representer_spec.rb
index cfd60f46e64..32a00bf7d42 100644
--- a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/work_package_representer_spec.rb
@@ -1018,7 +1018,10 @@ RSpec.describe API::V3::WorkPackages::WorkPackageRepresenter do
let(:link) { "timeEntries" }
let(:href) do
api_v3_paths.path_for(:time_entries,
- filters: [{ work_package_id: { operator: "=", values: [work_package.id.to_s] } }])
+ filters: [
+ { entity_type: { operator: "=", values: ["WorkPackage"] } },
+ { entity_id: { operator: "=", values: [work_package.id.to_s] } }
+ ])
end
let(:title) { "Time entries" }
end