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
Allow calling #create instead of #new on collection representers
Oliver Güntherf400e7b497f4
diff --git a/lib/api/decorators/single.rb b/lib/api/decorators/single.rbindex 6a30a20b23e..28f7f72bf99 100644--- a/lib/api/decorators/single.rb+++ b/lib/api/decorators/single.rb@@ -48,8 +48,10 @@ module API# Use this to create our own representers, giving them a chance to override the instantiation# if desired.- def self.create(model, current_user:, embed_links: false)- new(model, current_user: current_user, embed_links: embed_links)+ # Explicitly forwards all arguments to new, to avoid having to override #create on subclasses+ # such as collection+ def self.create(...)+ new(...)enddef initialize(model, current_user:, embed_links: false)diff --git a/lib/api/v3/utilities/endpoints/index.rb b/lib/api/v3/utilities/endpoints/index.rbindex 6285d50881c..015793496eb 100644--- a/lib/api/v3/utilities/endpoints/index.rb+++ b/lib/api/v3/utilities/endpoints/index.rb@@ -90,13 +90,13 @@ module APIresulting_params = calculate_resulting_params(query, params)render_representer- .new(results,- self_link: self_path,- query: resulting_params,- page: resulting_params[:offset],- per_page: resulting_params[:pageSize],- groups: calculate_groups(query),- current_user: User.current)+ .create(results,+ self_link: self_path,+ query: resulting_params,+ page: resulting_params[:offset],+ per_page: resulting_params[:pageSize],+ groups: calculate_groups(query),+ current_user: User.current)enddef render_unpaginated_success(results, self_path)