Sha256: 331733ac9fdc322096af09d86c6bd2c72cad4cb70e87c633643926529d3ceb6e
Contents?: true
Size: 1.39 KB
Versions: 2
Compression:
Stored size: 1.39 KB
Contents
require 'ostruct' class UiTemplateSyncsController < ApplicationController include ::Foreman::Controller::Parameters::TemplateParams rescue_from ::ForemanTemplates::PathAccessException do |error| render_errors [error.message] end def sync_settings import_settings = Setting.where :name => Setting::TemplateSync.import_setting_names(['verbose']) export_settings = Setting.where :name => Setting::TemplateSync.export_setting_names(['verbose']) @results = OpenStruct.new(:import => import_settings, :export => export_settings) end def import @parse_result = OpenStruct.new ForemanTemplates::TemplateImporter.new(ui_template_import_params).import! end def export @result = OpenStruct.new ForemanTemplates::TemplateExporter.new(ui_template_export_params).export! if @result.error render_errors [@result.error] end if @result.warning render_errors [@result.warning], 'warning' end end def action_permission case params[:action] when 'sync_settings' :view_template_syncs else super end end def parameter_filter_context Foreman::ParameterFilter::Context.new(:api, controller_name, params[:action]) end def render_errors(messages, severity = 'danger') render :json => { :error => { :errors => { :base => messages }, full_messages: messages, :severity => severity } }, :status => :unprocessable_entity end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
foreman_templates-9.1.0 | app/controllers/ui_template_syncs_controller.rb |
foreman_templates-9.0.2 | app/controllers/ui_template_syncs_controller.rb |