From 25bd49e4f57fe15f9d61dc9376a5b7dc35b30f64 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Wed, 3 Oct 2018 00:00:38 +0100 Subject: Backport project template API to CE --- lib/api/templates.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lib/api/templates.rb') diff --git a/lib/api/templates.rb b/lib/api/templates.rb index 8ff3b2ac33c..8dab19d50c2 100644 --- a/lib/api/templates.rb +++ b/lib/api/templates.rb @@ -35,7 +35,7 @@ module API popular = declared(params)[:popular] popular = to_boolean(popular) if popular.present? - templates = TemplateFinder.build(:licenses, popular: popular).execute + templates = TemplateFinder.build(:licenses, nil, popular: popular).execute present paginate(::Kaminari.paginate_array(templates)), with: ::API::Entities::License end @@ -48,8 +48,7 @@ module API requires :name, type: String, desc: 'The name of the template' end get "templates/licenses/:name", requirements: { name: /[\w\.-]+/ } do - templates = TemplateFinder.build(:licenses).execute - template = templates.find { |template| template.key == params[:name] } + template = TemplateFinder.build(:licenses, nil, name: params[:name]).execute not_found!('License') unless template.present? @@ -72,7 +71,7 @@ module API use :pagination end get "templates/#{template_type}" do - templates = ::Kaminari.paginate_array(TemplateFinder.new(template_type).execute) + templates = ::Kaminari.paginate_array(TemplateFinder.build(template_type, nil).execute) present paginate(templates), with: Entities::TemplatesList end @@ -84,7 +83,7 @@ module API requires :name, type: String, desc: 'The name of the template' end get "templates/#{template_type}/:name" do - finder = TemplateFinder.build(template_type, name: declared(params)[:name]) + finder = TemplateFinder.build(template_type, nil, name: declared(params)[:name]) new_template = finder.execute render_response(template_type, new_template) -- cgit v1.2.1