debian-mirror-gitlab/app/controllers/admin/services_controller.rb

41 lines
1,021 B
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
class Admin::ServicesController < Admin::ApplicationController
2016-08-24 12:49:21 +05:30
include ServiceParams
2015-09-11 14:41:01 +05:30
before_action :service, only: [:edit, :update]
2015-04-26 12:48:37 +05:30
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
2016-08-24 12:49:21 +05:30
if service.update_attributes(service_params[:service])
2017-08-17 22:00:37 +05:30
PropagateServiceTemplateWorker.perform_async(service.id) if service.active?
2015-04-26 12:48:37 +05:30
redirect_to admin_application_settings_services_path,
notice: 'Application settings saved successfully'
else
render :edit
end
end
private
def services_templates
2016-11-03 12:29:30 +05:30
Service.available_services_names.map do |service_name|
2015-04-26 12:48:37 +05:30
service_template = service_name.concat("_service").camelize.constantize
2016-11-03 12:29:30 +05:30
service_template.where(template: true).first_or_create
2015-04-26 12:48:37 +05:30
end
end
def service
@service ||= Service.where(id: params[:id], template: true).first
end
end