Welcome to mirror list, hosted at ThFree Co, Russian Federation.

boards_responses.rb « concerns « controllers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a145049dc7de3c71e8fafe23dac0357b330ce91b (plain)
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
module BoardsResponses
  def authorize_read_list
    authorize_action_for!(board.parent, :read_list)
  end

  def authorize_read_issue
    authorize_action_for!(board.parent, :read_issue)
  end

  def authorize_update_issue
    authorize_action_for!(issue, :admin_issue)
  end

  def authorize_create_issue
    authorize_action_for!(project, :admin_issue)
  end

  def authorize_admin_list
    authorize_action_for!(board.parent, :admin_list)
  end

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

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

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

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