2016-08-01 16:09:41 +00:00
|
|
|
class Projects::BoardsController < Projects::ApplicationController
|
2016-08-30 13:50:46 +00:00
|
|
|
include IssuableCollections
|
2016-08-15 22:50:23 +00:00
|
|
|
|
2016-10-05 19:24:29 +00:00
|
|
|
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
|
2016-10-05 20:08:55 +00:00
|
|
|
render json: serialize_as_json(@boards)
|
2016-10-05 19:24:29 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-08-08 22:03:41 +00:00
|
|
|
|
2016-08-01 16:09:41 +00:00
|
|
|
def show
|
2016-10-05 20:08:55 +00:00
|
|
|
@board = project.boards.find(params[:id])
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.json do
|
|
|
|
render json: serialize_as_json(@board)
|
|
|
|
end
|
|
|
|
end
|
2016-08-01 16:09:41 +00:00
|
|
|
end
|
2016-08-08 22:03:41 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def authorize_read_board!
|
2016-08-15 22:50:23 +00:00
|
|
|
return access_denied! unless can?(current_user, :read_board, project)
|
2016-08-08 22:03:41 +00:00
|
|
|
end
|
2016-10-05 20:08:55 +00:00
|
|
|
|
|
|
|
def serialize_as_json(resource)
|
|
|
|
resource.as_json(only: [:id, :name])
|
|
|
|
end
|
2016-08-01 16:09:41 +00:00
|
|
|
end
|