Files
archived-redmine-webhook/app/controllers/webhook_settings_controller.rb
2019-05-02 10:28:15 +09:00

37 lines
1.2 KiB
Ruby

class WebhookSettingsController < ApplicationController
before_action :find_project, :authorize
accept_api_auth :create, :update, :destroy
def create
webhook = Webhook.new(:project_id => @project.id)
webhook.url = params[:url]
if webhook.save
flash[:notice] = l(:notice_successful_create_webhook)
else
flash[:error] = l(:notice_fail_create_webhook)
end
redirect_to settings_project_path(@project, :tab => 'webhook')
end
def update
id = params[:webhook_id]
webhook = Webhook.where(:project_id => @project.id).where(:id => id).first
webhook.url = params[:url]
if webhook.save
flash[:notice] = l(:notice_successful_update_webhook)
else
flash[:error] = l(:notice_fail_update_webhook)
end
redirect_to settings_project_path(@project, :tab => 'webhook')
end
def destroy
id = params[:webhook_id]
webhook = Webhook.where(:project_id => @project.id).where(:id => id).first
if webhook.destroy
flash[:notice] = l(:notice_successful_delete_webhook)
else
flash[:error] = l(:notice_fail_delete_webhook)
end
redirect_to settings_project_path(@project, :tab => 'webhook')
end
end