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
Correclty check permission in schema for WP representer
Klaus Zanders14116d2082c1
diff --git a/lib/api/v3/work_packages/schema/work_package_schema_representer.rb b/lib/api/v3/work_packages/schema/work_package_schema_representer.rbindex 071dc445cad..fe72aa0c42c 100644--- a/lib/api/v3/work_packages/schema/work_package_schema_representer.rb+++ b/lib/api/v3/work_packages/schema/work_package_schema_representer.rb@@ -62,21 +62,21 @@ module APIopts, = argsopts[:attribute_group] = attribute_group property- super property, **opts+ super(property, **opts)enddef schema_with_allowed_link(property, *args)opts, = argsopts[:attribute_group] = attribute_group property- super property, **opts+ super(property, **opts)enddef schema_with_allowed_collection(property, *args)opts, = argsopts[:attribute_group] = attribute_group property- super property, **opts+ super(property, **opts)endend@@ -168,9 +168,9 @@ module APItype: 'Duration',required: false,show_if: ->(*) {- current_user.allowed_in_project?(:view_time_entries, represented.project) ||- current_user.allowed_in_work_package?(:view_own_time_entries, represented)- }+ current_user.allowed_in_project?(:view_time_entries, represented.project) ||+ current_user.allowed_in_any_work_package?(:view_own_time_entries, in_project: represented.project)+ }schema :percentage_done,type: 'Integer',diff --git a/lib/api/v3/work_packages/work_package_representer.rb b/lib/api/v3/work_packages/work_package_representer.rbindex 44c7cb1d92a..24b8e28dd41 100644--- a/lib/api/v3/work_packages/work_package_representer.rb+++ b/lib/api/v3/work_packages/work_package_representer.rb@@ -573,7 +573,16 @@ module APIdef view_time_entries_allowed?@view_time_entries_allowed ||=current_user.allowed_in_project?(:view_time_entries, represented.project) ||- current_user.allowed_in_work_package?(:view_own_time_entries, represented)+ view_own_time_entries_allowed?+ end++ def view_own_time_entries_allowed?+ @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)+ endenddef log_time_allowed?