2018-09-25 23:45:43 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-24 15:43:46 -04:00
|
|
|
class Projects::TemplatesController < Projects::ApplicationController
|
|
|
|
before_action :authenticate_user!, :get_template_class
|
|
|
|
|
|
|
|
def show
|
|
|
|
template = @template_type.find(params[:key], project)
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.json { render json: template.to_json }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def get_template_class
|
|
|
|
template_types = { issue: Gitlab::Template::IssueTemplate, merge_request: Gitlab::Template::MergeRequestTemplate }.with_indifferent_access
|
|
|
|
@template_type = template_types[params[:template_type]]
|
2018-07-02 06:43:06 -04:00
|
|
|
render json: [], status: :not_found unless @template_type
|
2016-06-24 15:43:46 -04:00
|
|
|
end
|
|
|
|
end
|