Module: BoardsResponses

Includes:
Gitlab::Utils::StrongMemoize
Included in:
Boards::IssuesController, Boards::ListsController
Defined in:
app/controllers/concerns/boards_responses.rb

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Instance Method Details

#authorize_action_for!(resource, ability) ⇒ Object


60
61
62
# File 'app/controllers/concerns/boards_responses.rb', line 60

def authorize_action_for!(resource, ability)
  return render_403 unless can?(current_user, ability, resource)
end

#authorize_admin_listObject


56
57
58
# File 'app/controllers/concerns/boards_responses.rb', line 56

def authorize_admin_list
  authorize_action_for!(board, :admin_list)
end

#authorize_create_issueObject


49
50
51
52
53
54
# File 'app/controllers/concerns/boards_responses.rb', line 49

def authorize_create_issue
  list = List.find(issue_params[:list_id])
  action = list.backlog? ? :create_issue : :admin_issue

  authorize_action_for!(project, action)
end

#authorize_read_issueObject


41
42
43
# File 'app/controllers/concerns/boards_responses.rb', line 41

def authorize_read_issue
  authorize_action_for!(board, :read_issue)
end

#authorize_read_listObject


37
38
39
# File 'app/controllers/concerns/boards_responses.rb', line 37

def authorize_read_list
  authorize_action_for!(board, :read_list)
end

#authorize_update_issueObject


45
46
47
# File 'app/controllers/concerns/boards_responses.rb', line 45

def authorize_update_issue
  authorize_action_for!(issue, :admin_issue)
end

#board_paramsObject

Overridden on EE module


7
8
9
# File 'app/controllers/concerns/boards_responses.rb', line 7

def board_params
  params.require(:board).permit(:name)
end

#board_path(board) ⇒ Object


25
26
27
28
29
30
31
# File 'app/controllers/concerns/boards_responses.rb', line 25

def board_path(board)
  if group?
    group_board_path(parent, board)
  else
    project_board_path(parent, board)
  end
end

#boards_pathObject


17
18
19
20
21
22
23
# File 'app/controllers/concerns/boards_responses.rb', line 17

def boards_path
  if group?
    group_boards_path(parent)
  else
    project_boards_path(parent)
  end
end

#group?Boolean

Returns:

  • (Boolean)

33
34
35
# File 'app/controllers/concerns/boards_responses.rb', line 33

def group?
  instance_variable_defined?(:@group)
end

#parentObject


11
12
13
14
15
# File 'app/controllers/concerns/boards_responses.rb', line 11

def parent
  strong_memoize(:parent) do
    group? ? group : project
  end
end

#respond_with(resource) ⇒ Object


76
77
78
79
80
81
82
83
# File 'app/controllers/concerns/boards_responses.rb', line 76

def respond_with(resource)
  respond_to do |format|
    format.html
    format.json do
      render json: serialize_as_json(resource)
    end
  end
end

#respond_with_boardObject


68
69
70
# File 'app/controllers/concerns/boards_responses.rb', line 68

def respond_with_board
  respond_with(@board) # rubocop:disable Gitlab/ModuleWithInstanceVariables
end

#respond_with_boardsObject


64
65
66
# File 'app/controllers/concerns/boards_responses.rb', line 64

def respond_with_boards
  respond_with(@boards) # rubocop:disable Gitlab/ModuleWithInstanceVariables
end

#serialize_as_json(resource) ⇒ Object


72
73
74
# File 'app/controllers/concerns/boards_responses.rb', line 72

def serialize_as_json(resource)
  serializer.represent(resource).as_json
end

#serializerObject


85
86
87
# File 'app/controllers/concerns/boards_responses.rb', line 85

def serializer
  BoardSerializer.new
end