gitlab-org--gitlab-foss/app/controllers/admin/services_controller.rb

39 lines
941 B
Ruby
Raw Normal View History

2015-02-12 01:34:41 +00:00
class Admin::ServicesController < Admin::ApplicationController
include ServiceParams
before_action :service, only: [:edit, :update]
2015-02-12 01:34:41 +00:00
def index
@services = services_templates
end
def edit
unless service.present?
redirect_to admin_application_settings_services_path,
alert: "Service is unknown or it doesn't exist"
end
end
def update
if service.update_and_propagate(service_params[:service])
2015-02-12 01:34:41 +00:00
redirect_to admin_application_settings_services_path,
notice: 'Application settings saved successfully'
else
render :edit
end
end
private
def services_templates
2016-08-31 18:15:43 +00:00
Service.available_services_names.map do |service_name|
2015-02-12 18:57:08 +00:00
service_template = service_name.concat("_service").camelize.constantize
2016-08-31 18:15:43 +00:00
service_template.where(template: true).first_or_create
2015-02-12 01:34:41 +00:00
end
end
def service
@service ||= Service.where(id: params[:id], template: true).first
end
end