BigW Consortium Gitlab

boards_controller.rb 778 Bytes
Newer Older
1
class Projects::BoardsController < Projects::ApplicationController
Phil Hughes committed
2
  include IssuableCollections
3

4 5 6 7 8 9 10 11
  before_action :authorize_read_board!, only: [:index, :show]

  def index
    @boards = ::Boards::ListService.new(project, current_user).execute

    respond_to do |format|
      format.html
      format.json do
12
        render json: serialize_as_json(@boards)
13 14 15
      end
    end
  end
16

17
  def show
18 19 20 21 22 23 24 25
    @board = project.boards.find(params[:id])

    respond_to do |format|
      format.html
      format.json do
        render json: serialize_as_json(@board)
      end
    end
26
  end
27 28 29 30

  private

  def authorize_read_board!
31
    return access_denied! unless can?(current_user, :read_board, project)
32
  end
33 34

  def serialize_as_json(resource)
35
    resource.as_json(only: [:id])
36
  end
37
end