1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
class Projects::DeployKeysController < Projects::ApplicationController
respond_to :html
# Authorize
before_filter :authorize_admin_project!
layout "project_settings"
def index
@enabled_keys = @project.deploy_keys
@available_keys = available_keys - @enabled_keys
end
def show
@key = @project.deploy_keys.find(params[:id])
end
def new
@key = @project.deploy_keys.new
respond_with(@key)
end
def create
@key = DeployKey.new(params[:deploy_key])
if @key.valid? && @project.deploy_keys << @key
redirect_to project_deploy_keys_path(@project)
else
render "new"
end
end
def destroy
@key = @project.deploy_keys.find(params[:id])
@key.destroy
respond_to do |format|
format.html { redirect_to project_deploy_keys_url }
format.js { render nothing: true }
end
end
def enable
project.deploy_keys << available_keys.find(params[:id])
redirect_to project_deploy_keys_path(@project)
end
def disable
@project.deploy_keys_projects.where(deploy_key_id: params[:id]).last.destroy
redirect_to project_deploy_keys_path(@project)
end
protected
def available_keys
@available_keys ||= current_user.accessible_deploy_keys
end
end