summaryrefslogtreecommitdiff
path: root/app/controllers/admin
diff options
context:
space:
mode:
authorMarin Jankovski <maxlazio@gmail.com>2015-02-11 17:34:41 -0800
committerMarin Jankovski <maxlazio@gmail.com>2015-02-11 17:55:33 -0800
commit6b4ddf2cc13eda5dd6df64bab6f95f88d64cd2fa (patch)
tree3b9b008d4528ce1dcd2b15ac144548a3f9f26ecd /app/controllers/admin
parent09d3d351a1a80032c4e9bf185a15ff95819a4da0 (diff)
downloadgitlab-ce-6b4ddf2cc13eda5dd6df64bab6f95f88d64cd2fa.tar.gz
Add admin services templates.
Diffstat (limited to 'app/controllers/admin')
-rw-r--r--app/controllers/admin/services_controller.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/app/controllers/admin/services_controller.rb b/app/controllers/admin/services_controller.rb
new file mode 100644
index 00000000000..5697e1a5492
--- /dev/null
+++ b/app/controllers/admin/services_controller.rb
@@ -0,0 +1,51 @@
+class Admin::ServicesController < Admin::ApplicationController
+ before_filter :service, only: [:edit, :update]
+
+ 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_attributes(application_services_params[:service])
+ redirect_to admin_application_settings_services_path,
+ notice: 'Application settings saved successfully'
+ else
+ render :edit
+ end
+ end
+
+ private
+
+ def services_templates
+ templates = []
+
+ allowed_templates.each do |service|
+ service_template = service.constantize
+ templates << service_template.where(template: true).first_or_create
+ end
+
+ templates
+ end
+
+ def allowed_templates
+ %w( JiraService RedmineService CustomIssueTrackerService )
+ end
+
+ def service
+ @service ||= Service.where(id: params[:id], template: true).first
+ end
+
+ def application_services_params
+ params.permit(:id,
+ service: [
+ :title, :project_url, :description, :issues_url, :new_issue_url
+ ])
+ end
+end