-
Notifications
You must be signed in to change notification settings - Fork 150
/
Copy pathlocks_controller.rb
38 lines (33 loc) · 1017 Bytes
/
locks_controller.rb
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
module Shipit
module Api
class LocksController < BaseController
require_permission :lock, :stack
params do
requires :reason, String, presence: true
accepts :lock_level, String
validates :lock_level, inclusion: { in: Shipit::Stack::LOCK_LEVELS }, allow_nil: true
end
def create
if stack.locked?
render json: {message: 'Already locked'}, status: :conflict
else
stack.lock(params.reason, current_user, lock_level: params.lock_level)
render_resource stack
end
end
params do
requires :reason, String, presence: true
accepts :lock_level, String
validates :lock_level, inclusion: { in: Shipit::Stack::LOCK_LEVELS }, allow_nil: true
end
def update
stack.lock(params.reason, current_user, lock_level: params.lock_level)
render_resource stack
end
def destroy
stack.unlock
render_resource stack
end
end
end
end